refering to an item in a list box

  • Thread starter Thread starter Ralph Heidecke
  • Start date Start date
R

Ralph Heidecke

I have a list box (call it Listbox1) on a form (call it Form1). In the list
box are records gathered from a query; there are 2 fields "Name" and
"Number". I want to gather the number from one of the records a user clicks
on and pass it to a query to print a report. How do I refer to the number in
the selected record in Listbox1 in VBA?

Thanks
 
If the number is the Bound Column of the list box, just use:
Forms!Form1!Textbox1

If is is not the bound column, use the Column property:
Forms!Form1!Textbox1.Column(1)
Note that Column is zero-based.

Assuming this is not a multi-select list box.
If you are trying to OpenRecordset(), be sure to concatenate the value into
the SQL string, i.e. you cannot simply embed that reference into the SQL
string.
 
Back
Top