Using a Form to select Criteria for a Query

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.
 
G

Guest

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.
 

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