Query between date range

E

Elaine

Hi, I have eight queries looking at some tables. For all the queries, I
would like to pull data within the same date range e.g. Aug 1 to 30. Instead
of type the date range eight times, I would like to setup a table containing
start date and end date. Is it possible for the query to lookup the two
fields in the date range table, and query data between the two dates? And
how?
Thanks.
 
K

KARL DEWEY

Use a form and refer to the text box in the open form like this as criteria --
Between [Forms]![YourForm]![StartDateTextBox] and
[Forms]![YourForm]![EndDateTextBox]
 
J

John W. Vinson/MVP

Elaine said:
Hi, I have eight queries looking at some tables. For all the queries, I
would like to pull data within the same date range e.g. Aug 1 to 30.
Instead
of type the date range eight times, I would like to setup a table
containing
start date and end date. Is it possible for the query to lookup the two
fields in the date range table, and query data between the two dates? And
how?
Thanks.

There are a couple of ways to solve this problem. Your table approach is
certainly one; you could have a one-record table with two fields [StartDate]
and [EndDate], add it to your query, and use a criterion of BETWEEN
[tablename].[StartDate] AND [tablename].[EndDate].

Perhaps simpler is to use a small unbound form frmCrit with two textboxes
txtStart and txtEnd; use a criterion >= CDate([Forms]![frmCrit]![txtStart])
AND < DateAdd("d", 1, [Forms]![frmCrit]![txtEnd]). Run the queries from the
form, using a command button or the like.

If you're opening query datasheets to view the results, consider instead
using a Form, perhaps with eight subforms.

John W. Vinson/MVP
 
Top