listbox - selected(0)

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

My form has a combobox (cmbLE) and a listbox (lstREffDate). The listbox is
populated with a single item via a query based on the combobox selection. I
need to pass the resulting listbox item to other queries. So I select the
item using VBA (see below). On the form, the item is highlighted by the VBA.
However, the item will not pass to other queries unless I actually click on
the item. Any thoughts on what I might be doing wrong??? Thanks in
advance!!!

Private Sub cmbLE_Change()
Me!lstREffDate.Requery
Me!lstREffDate.Selected(0) = True
 
Try setting the value of the list box:

Me.lstReffDate = Me.lstReffDate.ItemData(0)
 
Thanks, Allen. Unfortunately, it did not solve the problem. I still need to
click on the item in order to pass it to the query.
 
Did the item highlight?

Was the query already open before this?
If you close the query and re-open it, does it discover the new value?

What happens if you open the Immediate Window (Ctrl+G), and enter:
? Forms![Form1]!lstREffDate
replacing Form1 with the name of your form?
 
Thanks for the tip on using the Immediate Window! I discovered my typo :-)
Thanks again!!!

Allen Browne said:
Did the item highlight?

Was the query already open before this?
If you close the query and re-open it, does it discover the new value?

What happens if you open the Immediate Window (Ctrl+G), and enter:
? Forms![Form1]!lstREffDate
replacing Form1 with the name of your form?

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

CinqueTerra said:
Thanks, Allen. Unfortunately, it did not solve the problem. I still need
to
click on the item in order to pass it to the query.
 
Back
Top