passing listbox selection to a query

JimL

Registered User.
Local time
Yesterday, 23:15
Joined
Jul 9, 2019
Messages
20
I have created a listbox named CenterCombo which contains a field called 'LocationName1'.

I have used the following criterion in a query containing the field LocationName1: [Forms]![Center Level]![LocationName1]

Unfortunately, the query returns only the records associated with the first name in the listbox regardless of whatever field is selected.

Have I missed anything in the construction of the criterion?

Any and all help is greatly appreciated!

Thanks and Regards

JimL
 
Use the control name CenterCombo in the query criteria instead of the field name
 
Thanks so much, Isladogs! The solution works.

I am faced with the fact that the criterion passed to the query appears to remain in memory even though I have added a refresh command before the openquery command. The form needs to be closed and re-opened before a new listbox entry can be passed.

Again, much appreciated.

Regards

JimL
 
There should be no need to close and reopen the form.
What code are you using?
 
This is actually a combobox, not a listbox?
 
I am using the macro builder behind the button. The first action is refresh and the second action is to run the query.

Thanks
 
I am using the macro builder behind the button. The first action is refresh and the second action is to run the query.

I never use macros so can only offer general comments.
Perhaps I'm being dense but I'm not sure why you are refreshing before running the query.
Try requerying (or possibly refreshing) after the query.
 

Users who are viewing this thread

Back
Top Bottom