Query using date range entered by user

P

Pam

I created a query using the following information provided by Allen Browne in
a previous post here. However, when I run the query, I get ALL the records
that have a date in my date field, no matter what the date is. For example,
I input the StartDate as 11/1/08 or 11/1/2008 and the EndDate as 11/30/08 or
11/30/2008 and I still get records from 1/1/2008 and 12/5/2008. I get every
record that has a date. The only thing I don't get is records where the date
field is empty. What am I doing wrong?

To create the parameter query:

Create a query to use as the RecordSource of your report.
In query design view, in the Criteria row under your date field, enter:
= [StartDate] < [EndDate] + 1 (This is what I use in the "criteria" row)

Choose Parameters from the Query menu, and declare two parameters of type
Date/Time:
StartDate Date/Time
EndDate Date/Time
 
A

Allen Browne

There's an AND missing:
= [StartDate] AND < [EndDate] + 1

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Pam said:
I created a query using the following information provided by Allen Browne
in
a previous post here. However, when I run the query, I get ALL the
records
that have a date in my date field, no matter what the date is. For
example,
I input the StartDate as 11/1/08 or 11/1/2008 and the EndDate as 11/30/08
or
11/30/2008 and I still get records from 1/1/2008 and 12/5/2008. I get
every
record that has a date. The only thing I don't get is records where the
date
field is empty. What am I doing wrong?

To create the parameter query:

Create a query to use as the RecordSource of your report.
In query design view, in the Criteria row under your date field, enter:
= [StartDate] < [EndDate] + 1 (This is what I use in the "criteria"
row)

Choose Parameters from the Query menu, and declare two parameters of type
Date/Time:
StartDate Date/Time
EndDate Date/Time
 
P

Pam

Thanks, Allen ... that did it!

Allen Browne said:
There's an AND missing:
= [StartDate] AND < [EndDate] + 1

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Pam said:
I created a query using the following information provided by Allen Browne
in
a previous post here. However, when I run the query, I get ALL the
records
that have a date in my date field, no matter what the date is. For
example,
I input the StartDate as 11/1/08 or 11/1/2008 and the EndDate as 11/30/08
or
11/30/2008 and I still get records from 1/1/2008 and 12/5/2008. I get
every
record that has a date. The only thing I don't get is records where the
date
field is empty. What am I doing wrong?

To create the parameter query:

Create a query to use as the RecordSource of your report.
In query design view, in the Criteria row under your date field, enter:
= [StartDate] < [EndDate] + 1 (This is what I use in the "criteria"
row)

Choose Parameters from the Query menu, and declare two parameters of type
Date/Time:
StartDate Date/Time
EndDate Date/Time
 

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