Microsoft KB Archive/106308

{|
 * width="100%"|

PRB: List Box Displays #Error
'Article ID: Q106308

Creation Date: 04-NOV-1993

Revision Date: 19-SEP-1996' The information in this article applies to:


 * Microsoft Access versions 1.0 and 1.1

SYMPTOMS

A list box that is filled by a list function displays one row with the following text:

#Error CAUSE

There are no elements to display in the list box. Microsoft Access displays the #Error row to show the user that it cannot display any elements.

RESOLUTION

To work around this situation, return -1, rather than zero, as the number of elements to display.

STATUS

This problem no longer occurs in Microsoft Access version 2.0.

MORE INFORMATION

This article assumes that you are familiar with Access Basic and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information on Access Basic, please refer to the "Introduction to Programming" manual.

The code below shows how to handle the case in which there are no rows to display within the list box. For "Case 0," use an If statement to determine if there are any records to show; if there are not, set the return value to -1.

Option Explicit Function MyList (fld As Control, id, row, col, code) Static Entries Dim ReturnVal

ReturnVal = Null

Select Case code Case 0 Entries = 0 dbs(Entries) = Dir("C:\WINNT\*.INI") Do Until dbs(Entries) = "" Or Entries >= 127 Entries = Entries + 1 dbs(Entries) = Dir Loop

' If there are no entries to display, set the ' results to -1 so that #error, and horizontal ' scroll bar do not show and also so that the ' user cannot select any blank row in the list box.

If Entries = 0 Then ReturnVal = -1 Else ReturnVal = Entries End If

Case 1 ReturnVal = Timer Case 3 ReturnVal = Entries Case 4 ReturnVal = 1 Case 5 ReturnVal = -1 Case 6 ReturnVal = dbs(row) Case 9 End Select

MyList = ReturnVal

End Function REFERENCES

Microsoft Access "Introduction to Programming," page 82
 * }

-

"THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED 'AS IS' WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY." '' ©1997 Microsoft Corporation. All rights reserved. Legal Notices.

''

Additional reference words: 1.00 1.10 pounderror fill function

fillfunction

KBCategory: kbusage

KBSubcategory: FmsCmbo