How to filter records before opening a form?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How can I use a form to open another form and restrict the records show on
the opened form?
 
On the irst form, use unbound controls (text boxes, list boxes, combo
boxes...) to enter the criteria for filtering the records in the second
form.

Then make a query (or modify the existing one) to filter the records for the
second form, and use the controls on the first form in the query criteria;
for instance, if you want to filter on a first name field, put a textbox (or
whatever) on the first form, called, say, txtFirstName, and in the query,
add criterion:

Like Forms![FistFormName]![txtFirstName] & "*"

This will result in the query selecting all records with first name starting
with Jo when you enter Jo in txtFirstName, so John, Joan, Joanne, Joshua etc
will all be selected, while if txtFirstName is left blank, all records will
be selected. This will work with any number of controls/fields to filter on,
and will always filter only on those fields you have entered criteria for.

Make this query the recordsource for the second form.

Finally, put a command button on the first form to open the second one.

HTH,
Nikos
 
Back
Top