Query by month

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.
 
A

Allen Browne

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
 
M

Me!Frustrated = True

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
 

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