Parameter query to pull all data if no value entered.

Using Access 2002, I have a table with a date field.  I want to setup a paramter query that will either pull data as of a certain date entered or pull all data if no date is entered.  I can get the first part, but when no value is keyed I get no results.  How can I do this?
vsllcAsked:
Who is Participating?
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Connect With a Mentor Database ArchitectCommented:
Change YourDateFieldName to the Name of your actual date field.

SELECT Table1.*
FROM Table1
WHERE (((Table1.YourDateFieldName)=IIf(IsNull([Enter Date]),[YourDateFieldName],[Enter Date])));

mx
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
Example:

SELECT Table1.*
FROM Table1
WHERE (((Table1.NotifyByDate)=IIf(IsNull([Enter Date]),[NotifyByDate],[Enter Date])));


mx
0
 
vsllcAuthor Commented:
Works!  Thanks.
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
You are welcome ...
mx
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.