When you have selection criteria for more than one field in a query, or you would like to give the user a combo box to select the criteria from, here's how to build a form to collect the input and then refer back to those values in the form.
1. Say you have a table with two fields (Table1, FieldA, FieldB).
2. Create a blank form with no underlying table or query (Form1).
3. Add 2 comboboxes (cboValueA & cboValueB) to your form using the wizard.
4. To write your query, go into design view for a new query.
5. Click on the View button (the leftmost button) on the query toolbar.
6. Paste in this SQL statement:
SELECT Table1.FieldA, Table1.FieldB FROM Table1
WHERE (((Table1.FieldA)=[forms]![Form1]![cboFieldA])
AND ((Table1.FieldB)=[forms]![Form1]![cboFieldB]));
7. Click on the Design View button again to return to the Grid and close (save) the query.
8. Open Form1 and drag a button to your form using the wizard
9. Select Miscellaneous, Run Query, Query1.
10. Test! Test! Test!
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.