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

Set Query Criteria using a Form

Status
Not open for further replies.

illini

Technical User
Aug 2, 2002
89
FR
I would like to have a form with select search criteria (using ComboBox,ListBox,ect...).

After the user selects the various criteria and clicks on a Cmd_Button, the Query is launched via DoCmd. The problem I'm faced with is that unless all of the fields are filled on the form, the query results in zero records found.

Is there a way to have the query recognize an empty field on the form as a desire to have all records? -illini
 
Try rebuilding your query, using your form and field names. Put this in the criteria row for each of the field columns the user can search on from your form.

[Forms]![frmYourForm]![YourControlName] or [Forms]![frmYourForm]![YourControlName] Is Null

Good Luck!
 
Thanks for the input.

I tried your suggestion. It did allow all of the records, but when I tried to specify only certain records (by inputing data in the field on the form), I still received all records.

The form is set up to provide certain query criteria. If the user choses to query records where field_1 = 'A', then only those records should appear. However, if field_1 is left blank, then all records (where field_1 = 'A', 'D', ect...) should be shown.

Do you have any other suggestions? -illini
 
Can anyone give me some further direction on this? I've found that if I narrow the query to one field, the above reccommendation works. However, mulitple fields still pose a problem. -illini
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top