PRB: List Box Displays #ErrorArticle ID: Q106308
SYMPTOMS
#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
STATUS
MORE INFORMATION
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