Date range parameters

A

Al Camp

In a query, in a date field, I have the following
parameter/criteria...
Between [Enter Start Date] And [Enter End Date]

I'd like to offer the user the option of entering a date range to
limit
the resulting records,
OR... enter nothing in response to the parameters, and get ALL
dates returned.

In this non-date example...
Like [Enter Customer Name] & "*"
the user can just hit the ENTER key, and all Customer Names will
be displayed.

Can I do the same for my DATE parameters??

Thanks,
Al Campagna
 
R

Rick B

Use an IF statement. Something like...

IIF Enter Start Date not null and Enter End Date not null then between start
and end, otherwise, show all.

Rick B


In a query, in a date field, I have the following
parameter/criteria...
Between [Enter Start Date] And [Enter End Date]

I'd like to offer the user the option of entering a date range to
limit
the resulting records,
OR... enter nothing in response to the parameters, and get ALL
dates returned.

In this non-date example...
Like [Enter Customer Name] & "*"
the user can just hit the ENTER key, and all Customer Names will
be displayed.

Can I do the same for my DATE parameters??

Thanks,
Al Campagna
 
F

fredg

In a query, in a date field, I have the following
parameter/criteria...
Between [Enter Start Date] And [Enter End Date]

I'd like to offer the user the option of entering a date range to
limit
the resulting records,
OR... enter nothing in response to the parameters, and get ALL
dates returned.

In this non-date example...
Like [Enter Customer Name] & "*"
the user can just hit the ENTER key, and all Customer Names will
be displayed.

Can I do the same for my DATE parameters??

Thanks,
Al Campagna

Try it like this:

WHERE YourTable.DateField Between [EnterStart] And [EnterEnd] OR
YourTable.DateField) Like IIf(IsNull([EnterStart]),"*");
 
A

Al Camp

Fred,
Just the ticket!!
Thanks a lot,
Al Campagna

fredg said:
In a query, in a date field, I have the following
parameter/criteria...
Between [Enter Start Date] And [Enter End Date]

I'd like to offer the user the option of entering a date range to
limit
the resulting records,
OR... enter nothing in response to the parameters, and get ALL
dates returned.

In this non-date example...
Like [Enter Customer Name] & "*"
the user can just hit the ENTER key, and all Customer Names will
be displayed.

Can I do the same for my DATE parameters??

Thanks,
Al Campagna

Try it like this:

WHERE YourTable.DateField Between [EnterStart] And [EnterEnd] OR
YourTable.DateField) Like IIf(IsNull([EnterStart]),"*");
 

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

Similar Threads

parameter date question 3
criteria for date range 10
Criteria For Date Range 2
report based query 7
Parameter Query 5
Date Range Prompt 5
Date Range Parameters 4
Excel Date Setting 1

Top