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

single date or a date range entered 1

Status
Not open for further replies.

srenner

MIS
Jun 6, 2002
4
US
I am trying to write a query that would enable me to search on a single date or a date range entered on a "Report Criteria Form".

The criteria specified in the query is:

Between [Forms]![Report Criteria Form]![Start Date] And [Forms]![Report Criteria Form]![End Date]

It seems to work okay for a range of dates.

However it does not pull up records when the SAME date is entered in BOTH Start and End Date fields on the Report Criteria Form. I would like to add functionality to search for a single date OR range of dates.

What's the best way to modify this query to use only [Start Date] IF [End Date] is null or equal to the [Start Date], OTHERWISE use the full range between [Start Date] and [End Date]?

Many thanks for your assistance

Sylvester
 
If you make sure that the user enters a date for both start date and end date then you could use something like this:

>=[Forms]![Report Criteria Form]![Start Date] And <=[Forms]![Report Criteria Form]![End Date]

I think the problem you are getting with your between statement is that nothing is between the same number, I believe it's like using > and < instead of >= and <= if that makes sense. Hope that helps.
 
Thanks godawgs

I modified query to finally look like this...

>=[Forms]![Report Criteria Form]![Start Date] And <[Forms]![Report Criteria Form]![End Date]+1

* removed = sign
* added +1

Works great
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top