Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Refreshing listboxes on a form 2

Status
Not open for further replies.

KalEl33

Programmer
May 20, 2002
17
US
I am having some trouble with no data appearing my listboxes.

The way the form works is that when the form opens, a combobox will get a value using DLookup from a table. This part works fine. The listboxes then run a query using the data from the combobox. The problem is that the listboxes remain blank. (Note: this whole process requires no input from the user). I think I need to refresh or requery (Not quite sure which) the form in order to make the data appear in the listboxes, but I'm not quite sure how to do this. I have tried writing the following in the form's OnLoad, OnOpen, OnCurrent etc. but it doesn't seem to work:

Forms!frmConfirmUpdate.Requery
Forms!frmConfirmUpdate.Refresh

Me.Requery
Me.Refresh

I have noticed that if I go into design view then back into form view, the values will appear in the listboxes.

Thanks in advance for your help.

Sincerely,
Kal-El
 
You should requery the Listbox if you change it's rowsource.

If you are setting a new Rowsource for a list box based on the value of a combo box, I would do something like this.

For the combo box afterupdate event:

Sub Combo1_afterupdate()

ListBox1.Rowsource = "SELECT stuff FROM sometable WHERE stufftype='" & combo1 & "'"
ListBox1.Requery

end sub

You may also have to force the listbox to requery in the forms "Onopen" event.
Something like this:

sub form_open()
Combo1_afterupdate
end sub
 
Thanks for the help. You advise really helped.

Sincerely,
Kal-El
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top