Query by month

  • Thread starter Thread starter Humbled Learner
  • Start date Start date
H

Humbled Learner

I have a query which returns all information from two tables.

I would to build a search form which askes for beginning and closing date.
After adding the dates, I would like a query (or report) to open in a subform
and reflect the rows from the query only between those dates.

I know how to build the form and subform, just not complete the search and
results.

Where do I start?

Thank You.
 
In the Criteria row of the query, under your data field, enter something
like this (as one line):
= [Forms].[Form1].[txtStartDate] And < [Forms].[Form1].[txtEndDate] + 1

Substitute your search form's name for Form1, and your textbox names for
txtStartDate and txtEndDate.

If these controls are unbound, declare the parameters in the query to ensure
Access understands the data type. In query design view, choose Parameters
from the menu/ribbon. Access opens a dialog, where you enter 2 rows like
this:
[Forms].[Form1].[txtStartDate] Date/Time
[Forms].[Form1].[txtEndDate] Date/Time

For more details, and another possible approach, see:
Limiting a Report to a Date Range
at:
http://allenbrowne.com/casu-08.html
 
If you already have controls on your form for the two dates, enter this in
the 'Criteria' for the date field in your query:

Between [Forms]![myForm]![startdate] And [Forms]![myForm]![closingdate]

replace 'myForm' with the name of your form for entering dates, replace
'startdate' and 'closing date' with the names of the controls on the form.

To display the results in the subform, set its Record Source to that query.

hth
 
Back
Top