How do I create a search form in Access?

M

Megan

I want to create a form that has multiple criteria for people to search by,
which will then link to a filtered version of forms matching their criteria
.... everything I try does not work. Please help of you can
 
B

Bob Howard

Megan;

One method that's worked for me is to:
1) put unbound controls on the form representing the fields the user can
enter for the search;
2) code the query (that is the RecordSource for the search form) so that it
contains one calculated field for each comparison
2a) each calculated field contains an "IIF" comparing the search control
against the actual data in the table
2b) if there is a match, set the result of the "IIF" to "Yes"
2c) otherwise set the result of the "IIF" to "No"
2d) in the Criteria row, enter "Yes"
[the result is that only those rows that meet all the search arguments
will be in the result]
3) but a button on the form
4) after the user enters the information, he/she clicks this button
5) code an OnClick event for the button and in the OnClick event, issue a
DoCmd.Requery so that the query will be executed using the search
information entered by the user.
6) code the appropriate bound controls on the form to display the results.

Bob (@Martureo_Org)
 
T

Tatakau

Just what I was looking for!

Though I did have a few questions about how to implement it. The technical
details are rather lost to me. Could you perhaps show me sample code for one
field in step 2? Or are you changing the properties of the fields?

Thanks!

Nick

Bob Howard said:
Megan;

One method that's worked for me is to:
1) put unbound controls on the form representing the fields the user can
enter for the search;
2) code the query (that is the RecordSource for the search form) so that it
contains one calculated field for each comparison
2a) each calculated field contains an "IIF" comparing the search control
against the actual data in the table
2b) if there is a match, set the result of the "IIF" to "Yes"
2c) otherwise set the result of the "IIF" to "No"
2d) in the Criteria row, enter "Yes"
[the result is that only those rows that meet all the search arguments
will be in the result]
3) but a button on the form
4) after the user enters the information, he/she clicks this button
5) code an OnClick event for the button and in the OnClick event, issue a
DoCmd.Requery so that the query will be executed using the search
information entered by the user.
6) code the appropriate bound controls on the form to display the results.

Bob (@Martureo_Org)

Megan said:
I want to create a form that has multiple criteria for people to search by,
which will then link to a filtered version of forms matching their criteria
... everything I try does not work. Please help of you can
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top