Date Range Parameters

A

AlCamp

I often use Date Range Parameters to allow users to select a report date
range.
Between [Start Date] And [End Date]

I also use...
Like [Enter Text or Number] & "*"
that will allow the user to just hit Enter in response to the [Enter Text or
Number] parameter... and retrieve ALL records.

How can I gain that criteria "flexibility" when using Date values?

If the user just hits the Enter key in response to the [Start Date]
parameter, and just the Enter key in response to the [End Date] parameter,
I'd like to return ALL dates.

I've thought of doing an IF where... if IsNull([Start Date]) then [Start
Date] = #1/1/1945#...
and [End Date] = #1/1/12050#. But, that's pretty ugly...

Thanks for any assistance in advance...

Al Camp
 
D

Douglas J. Steele

You can use SQL like:

WHERE MyDate = [Start Date] OR [Start Date] IS NULL
 
P

PC Datasheet

Between NZ([Forms]![MyForm]![MyStartDate], #1700-01-01#) and
NZ([Forms]![MyForm]![MyEndDate], #9999-12-31#)


Note: Modify the dates in the above to a range that won't possibly exclude
any of your records.
 
A

AlCamp

Excellent Doug. I knew there had to be a more elegant way...
Thanks a lot for that info.
Al Camp

Douglas J. Steele said:
You can use SQL like:

WHERE MyDate = [Start Date] OR [Start Date] IS NULL

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



AlCamp said:
I often use Date Range Parameters to allow users to select a report date
range.
Between [Start Date] And [End Date]

I also use...
Like [Enter Text or Number] & "*"
that will allow the user to just hit Enter in response to the [Enter Text
or
Number] parameter... and retrieve ALL records.

How can I gain that criteria "flexibility" when using Date values?

If the user just hits the Enter key in response to the [Start Date]
parameter, and just the Enter key in response to the [End Date]
parameter,
I'd like to return ALL dates.

I've thought of doing an IF where... if IsNull([Start Date]) then [Start
Date] = #1/1/1945#...
and [End Date] = #1/1/12050#. But, that's pretty ugly...

Thanks for any assistance in advance...

Al Camp
 
A

AlCamp

PC,
Very interesting use of the NZ function... I will give it a try.
Thanks for the help.
Al Camp

PC Datasheet said:
Between NZ([Forms]![MyForm]![MyStartDate], #1700-01-01#) and
NZ([Forms]![MyForm]![MyEndDate], #9999-12-31#)


Note: Modify the dates in the above to a range that won't possibly exclude
any of your records.


--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
(e-mail address removed)
www.pcdatasheet.com






AlCamp said:
I often use Date Range Parameters to allow users to select a report date
range.
Between [Start Date] And [End Date]

I also use...
Like [Enter Text or Number] & "*"
that will allow the user to just hit Enter in response to the [Enter Text or
Number] parameter... and retrieve ALL records.

How can I gain that criteria "flexibility" when using Date values?

If the user just hits the Enter key in response to the [Start Date]
parameter, and just the Enter key in response to the [End Date]
parameter,
I'd like to return ALL dates.

I've thought of doing an IF where... if IsNull([Start Date]) then [Start
Date] = #1/1/1945#...
and [End Date] = #1/1/12050#. But, that's pretty ugly...

Thanks for any assistance in advance...

Al Camp
 

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