Parameter Query help

  • Thread starter Thread starter tom
  • Start date Start date
T

tom

Hello

Ive got a query where the contents are sorted by 3 paramter queries.

The first is on the client type field. It can either be yes or no, or leave
it blank to get see all records. This is using Is Null

The Second and Third parameters are a between date and date. Ive also added
the Is Null part to the end so that all records can be seen if they are left
blank.

The problem im having is that when one of the queries is left blank, i dont
get any results for the query at all. Wheras if i enter values into each
query it works fine, and if i leave them all blank it works fine.

Thankyou for any help
 
After each reference to a parameter in your WHERE clause, add "OR
[Parameter] IS NULL"

You'll also need to use Parentheses to ensure that the boolean operations
are done correctly.

In other words, if you've got:

WHERE Field1 = [Parameter 1]
AND Field2 = [Parameter 2]

you want

WHERE (Field1 = [Parameter 1] OR [Parameter 1] IS NULL)
AND (Field2 = [Parameter 2] OR [Parameter 2] IS NULL)
 
Back
Top