It there anyway to have a list box in a query? For Ex. in the Criteria box in
order for a msg box to display you have to enter [] then you can "type" in
what you want it to search for. My question is can I have a drop down box in
that Messagebox?
No you cannot use a drop-down box in the query prompt.
But you can use a drop-down (combo box) to find the correct value and
refer to that in the query.
By the way, there is a difference between a List Box and a Drop-down
box (a Combo Box).
You'll need to use a form to do this.
I'll assume, since you didn't state otherwise, that the query is all
you want to run, and it is not used as the recordsource of a report.
If it is to be used as a report's recordsource, you'll have to post
back.
I'll use a combo box to find the correct CompanyID value wanted to
filter the query on. Change as needed.
Make a new unbound form.
Add a combo box that will show the CompanyID field and CompanyName.
Make sure the Combo Box Bound Column is Column 1 and is the
same DataType as the CompanyID field in the query.
You can hide the CompanyID field by setting the combo widths property
to:
0";1"
Add a command button.
Code the button's Click event:
DoCmd.OpenQuery "QueryName"
DoCmd.Close acForm, Me.Name
Name this form "ParamForm"
In the query, on the CompanyID field 's criteria line, write:
forms!ParamForm!ComboBoxName
Open the form.
Find the ComapanyName in the combo box.
Click the command button.
The query will display just those records selected.
The Form will close.