listbox - selected(0)

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
 
A

Allen Browne

Try setting the value of the list box:

Me.lstReffDate = Me.lstReffDate.ItemData(0)
 
G

Guest

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.
 
A

Allen Browne

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?
 
G

Guest

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top