Access: Running a Query Using a Filter Dialog Box in a Form
Parameter queries are quite handy to use when you know what to type when the prompt appears. However, have you thought how great it would be if you could create a parameter query in Access with a drop-down list – with options from which to choose? A simple form with a drop-down list, such as the one shown here, allows the user to run a query to view equipment records based on the Manufacturer criteria selected from this drop-down list:

The best way to create a drop-down list is to create a simple form with a combo box that can be referenced by the query. The form and the query work together to provide the desired dataset.
There are three basic steps that are necessary:
- Create the form with the combo box(es) that will supply the parameters for the query.
- Create the query with an expression that will reference the form.
- Add Command Buttons to the form to run the query and to close the form.
Adding a Combo Box to the Form
Suppose you are tracking equipment inventory, and you would like to view a list of manufacturers and the corresponding equipment along with purchase prices. In a blank form, first you must create a combo box. It may be easier to use the Combo Box Wizard.
- Create and save a new blank form in Design view. (You will have more flexibility in Design view).
- In the Toolbox, click Combo Box and click in the form where you want it to appear. (Make sure that the Wizard tool is enabled).
- On the Combo Box Wizard dialog box, Click “I want the combo box to look up the values in a table or query.”
- Click Next.
- Choose the primary table on the “one” side of the relationship that contains the unique field values, which you want to filter. Continue through the Combo Box Wizard choosing the appropriate fields, sort options, width of columns, etc.
- When finished, view the form. Make size or label name adjustments as necessary.
- You may want to change the following Form properties In the Form property sheet:
- Pop Up = “Yes”
- Border Style = “Dialog”
- Control Box = “No”
- Close Button = “No”
- Give the combo box control a meaningful name, which will be used in the query.
- Create additional combo boxes for additional filtering, if desired.
- Close the form. (In Form view, you can right-click on the form to close it).
Creating the Query to Reference the Form Control
Next you must create a query since the query name will have to be referenced within the form. This query is very similar to creating a parameter query, but you will reference the form control instead.
- Make sure that the one-to-many relationships have been defined between tables. In this example, the Manufacturers and Equipment tables are joined by the Manufacturer field.
- Create a query using the fields from appropriate tables that will display the required data.
- In Design view, you will need to reference the field that has the drop-down list in the form (in this case, it would be the Manufacturer field). However, instead of using bracketed parameters as you would in a parameter query, you will include the name of the form and the name of the combo box control within brackets as follows:
[forms]![FormName]![ComboBoxName]
The query Criteria field in Design view could be structured something like this:
Depending upon the version of Access you are using, Access may prompt you with the correct names for the form references, which is a new feature in Access 2010. Also, if you wish to use wildcard characters when selecting criteria in the form, so that you may enter a partial text string with an asterisk, then the line should read:
Like [forms]![FormName]![ComboBoxName] & “*”
Save and close the query.
Adding the Command Button to Run the Query
The query should now work when you choose an item from the drop-down list in the form; however, the query will have to be opened manually after you choose an item in the drop-down list in the form. Therefore, you will want to add a command button to the form so that the query will run automatically.
- Open the form in Design view.
- Click the Command Button tool on the Ribbon; then click in the form where you want the command button to appear.
- When the Command Button Wizard opens, choose the Miscellaneous category and the “Run Query” action.
- Click Next; choose the query that you created to run when the command button is selected.
- Click Next; choose the text or picture for the button.
- Click Finish.
- Save the form.
- Switch to Form view and test the command button.
Note: If you leave the query open when changing options in the drop-down box in the form, you will have to keep refreshing the query to see the updated results. The keyboard shortcut is F5 to refresh.
Adding the Command Button to Close the Form
Next you will want to add a command button to the form to close the form.
- Switch to Design view.
- Click the Command Button tool on the Ribbon; then click in the form where you want the command button to appear.
- When the Command Button Wizard opens, choose the Form Operations category and the “Close Form” action.
- Click Next; choose the text or picture for the button.
- Click Finish.
- Save the form.
- Switch to Form view and test the command button.


December 20th, 2010 at 10:57 am
Thanks for the great tip! Is there a way to keep the resulting query on the same form?
March 17th, 2011 at 8:15 am
Hi,
This article is very good article because it has many valuable side.
January 17th, 2012 at 2:04 pm
This piece is exactly what I needed. Thanks!
Like [forms]![FormName]![ComboBoxName] & “*”
December 18th, 2012 at 10:27 am
Thank for your advice.It is great
February 21st, 2013 at 4:26 pm
Thank you for this great step by step. This helped me so much, much more than the access help topics! Thank you!!
April 5th, 2013 at 10:27 am
Hi there, I am actually having a problem with this now that I can’t seem to find the answer to anywhere. It works fine right after I do it. I save everything. But then when I open the database again, it does not work anymore. I get a box that pops up asking me to enter the parameter value for [forms]![Home]![combobox]. I try renaming the combobox and changing the parameter in my query and it works again, but then when I open my database it starts all over again.
April 5th, 2013 at 12:47 pm
Jallison,
First make sure the name of the combo box matches that in the query. You might also try deleting and re-entering the entire line of criteria in the query and saving. You will get the pop-up box asking for a parameter value unless you open the form first and select an option in the drop-down. Once something has been selected from the drop-down within the form, the query can be opened and should keep displaying the results correctly, based on the drop-down selection in the form.
April 12th, 2013 at 4:24 pm
Hi
I think this is great. [forms]![FormName]![ComboBoxName] works perfectly for me.
But I have a question what if I want to drag that form into a navigation form. How should I write the reference field.
Like the above example: [forms]![frmviewEquip]![Cbomanuf] , If I want to drag the “frmviewEquip” form in the navigation form (named frmMain, for example) under navigation control (named equipment), what should I write for the reference field. I have a hard time figuring out this. Any suggestions would be great.
April 15th, 2013 at 3:10 pm
Bu Xu,
This is a good question. I can only get this to work by dragging in the form to the Detail area in Design view which caused the form to be placed into the main control area. Therefore, I had to first remove the navigation subform and the navigation buttons or the form would show on top of any other Access objects under the other buttons. Therefore, I don’t think this would be very helpful. This is something I can keep experimenting with.
This reference in the query did work, however: [forms]![frmMain]![frmviewEquip]!![Cbomanuf] -assuming that frmMain is the name of the navigation form.
May 7th, 2013 at 6:17 pm
Hi, me being quite a newbie in access, would you mind explain me if there’s a way to make query results automatically refresh (instead of hitting f5) subsequent to the changes in user form? (without closing the query). any help is much appreciated. regards.
May 10th, 2013 at 8:07 am
Hello, I have entered this reference in my query and it works great,,,,,1 time. When I go to choose a different , customer, in my case, nothing is returned on my query. And there are records with the customer’s name that I have choosen. If I completly delete the reference line in the query and re-add it, save, and then close, when I go to my form, enter a customer name from the drop down, and then hit run query, I will get my results. And then I’m left with deleting the reference line again to make it work a second time. Can anyone help??? I have searched and tried everything I know to try…