Using a Form to select Criteria for a Query

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

Guest

Hello,

I've created a form within my database to allow the users to use combo boxes
to select criteria for Querying their Data. For instance, the form has combo
boxes for zip code, foreman, estimator, sales price, etc. When the user
selects a zip code it becomes the criteria on which the data is queried.

The problem I'm having is when setting up these multiple criteria, its
messing up my query. If the user does not want to query a zip code, they
would leave that field blank giving that box a null value. My query is then
looking for the records where the zip code is null. This gives me no
records.

I guess I need the query to ignore the combo boxes where the value is null
and only use the boxes with a value. How do I tell the query this?

Thanks.
 
To include the option for Null use the following syntax on the criteria line
for every form control referenced in your query:

Forms!YourFormName!YourFormControlName OR
Forms!YourFormName!YourFormControlName Is Null

As an example:

Forms!frmSearch!ZipCode OR Forms!frmSearch!ZipCode Is Null

When you exit the query, Access will build all combinations for the use of
Null.
 
Back
Top