• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 30. Working with ADO Recordsets,... > Filling List Boxes from Recordset Ob...

Filling List Boxes from Recordset Objects

You can use techniques similar to those for combo boxes to populate list boxes. List boxes that include many fields, have column headings, or both require additional code. You must test for queries that return no records and value lists with lengths greater than 2,047 characters. If your list box includes column headings, you must add the headings to the value list before appending rows from the Recordset. One benefit of using a Recordset is that you can detect RecordCount = 0 and display a message box that the query returned no records.

You use the rstName.Fields(n).Name property value, where n equals 0 to one less than the rstName.Fields.Count value, to supply the value list elements for the column names. Although you could manually assign the list of field names to the beginning of the value list string, using the Name property of the Field object is a good programming practice because it makes your code more generic.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint