Fill Listbox with recordset Project VBA

  • Thread starter Thread starter Goofy
  • Start date Start date
G

Goofy

Hi,

I have retreived a recordsed from an SQL ODBC driver and want to fill my
listbox with those records. I want to be able to retreive a value from the
list whilst displaying a text description.

Can anyone help ?
 
If you are saying you will have in the recordset a field that contains the
value you want to retrieve and a field that containg the text description,
you can use either the recordset or a query based on the recordset that
contains only those two fields, you can make the table/query the record
source for your list box. You can set the column width of the value column 0
so the user sees only the text description. Once a selection is made, you
can select which column you want to return for your value.

One note, the only reason to use a list box in a case like this is if you
want the user to be able to select multiple rows. If they will be selecting
only one row, I would recommend you use a combo box instead. It is easier to
deal with in VBA and from the user perspective, it provide the Auto Expand
(type aheand) property the list box does not have. If there a many records
in the recordset, finding a record with a list box is harder for a user. If
the recordset is large, take a look at this site. It will help performance
using a combo with a lot of records

http://allenbrowne.com/ser-32.html
 
Back
Top