Query Criteria

  • Thread starter Thread starter Melissa
  • Start date Start date
M

Melissa

I have a form that contains 2 drop down boxes and a query
that references these drop down boxes in order to set the
criteria. I.e. using =Forms!frmInputs!Company

Sometimes I need the query to filter on both fields, which
works fine. The problem I am having is that sometime I
only need the query to filter on the first drop down box
and not the second. Using the universal code * in the 2nd
box does not work because if you put this value into the
drop down box it looks for records with "*" and returns
nothing.

I think that I could use SQL code to get this working, but
I am unfamilar with it. Can I use "if - then" statements
in SQL query code?

Any help on this issue would greatly be appreciated!

Thank you so much,
Melissa
 
If you use "*" and using "=" (default) as your criteria.
It will find record that only have "*" in the field.
However, if you use "like" instead of "=". It will treat
the "*" as a wildcard which will match anything.

Hope this will help.
 
I have a form that contains 2 drop down boxes and a query
that references these drop down boxes in order to set the
criteria. I.e. using =Forms!frmInputs!Company

Sometimes I need the query to filter on both fields, which
works fine. The problem I am having is that sometime I
only need the query to filter on the first drop down box
and not the second.

Use a criterion on the second field such as

=Forms!frmInputs!controlname OR Forms!frmInputs!controlname IS NULL

If the user enters data in the control the first clause will check it;
if they don't, the second clause will be TRUE and Access will retrieve
all the records.
 
Back
Top