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

IIF and Null in query

Status
Not open for further replies.

ccjjscb

Technical User
Jan 18, 2006
29
US
Searched but could not find an answer to this one. I have a form that runs a query that returns a set of records for a report. The query has a date field that corresponds to the field on the record. My form has Unbound text boxes for to and from dates. I want to be able to query the records based on the to and from boxes on the form but also be able to pull in all records for all dates if these text boxes are left blank. I thought maybe a IIF staement with a statement thats says iff the text boxes are blank (Null) give all dates and if not give records between the from box and the to box. Hope someone can make out what I am trying to say here. I tried several times but am not all that great with the language. Any help or suggestions would be great. P.S. The query works fine with just the Between staement or just leaving it blank, I just want it both ways.
Thanks
Chris
 
A starting point (WHERE clause in SQL):
Code:
WHERE ([your date field]>=[your from control] OR [your from control] Is Null)
  AND ([your date field]<=[your to control] OR [your to control] Is Null)

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top