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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get selection criteria from a form

Queries

Get selection criteria from a form

by  elizabeth  Posted    (Edited  )
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!
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top