first_page the funky knowledge base
personal notes from way, _way_ back and maybe today

Access to VB: Combo And List Boxes

The ItemData(<index>) property in Visual Basic is an array of long integers corresponding with the List(<index>) property of the combo box or list box. For an unbound list or combo box control in Access, ItemData(<index>) returns the first column of the query, table or dynamic SQL specified in the RowSource property assignement. (Note that if the ColumnHeads property is True, ItemData(0) will return the column heading.)

With the above in mind, we can design an Access project being aware of the following:

Think of VB combo and list boxes as having a two-column "RowSource," where the first column---represented by ItemData(<index>)---is "hidden" (in Access this would be a column of width zero). The second column, containing strings, is displayed and is represented by the List(<index>) property.

VB has no run-time equivalent to the RowSource property in Access. VB's AddItem method must be used to populate the combo or list box.

In Access, fill combo and list boxes from data sources with an ID column in data type long integer. In VB, the AddItem method can be wrapped in a Do loop reading from the same or a similar data source.

VB has no intrinsic equivalent to Columns(<index>). VB and Access both have the ListIndex property.

mod date: 1998-11-01T06:25:31.000Z