Constrain Report based on date range

loki1049

Registered User.
Local time
Today, 01:57
Joined
Mar 11, 2010
Messages
28
Hi, I'm new to this whole reporting thing, but pretty familiar with queries and forms. I would like to report off of a table, but use a form to run the report based on a date range. So I choose a start date and end date and then hit a button to open my report and display my formatted data for only that range.

How would one go about doing something like this? I'm not even sure how to filter records on the reporting side, which is what I would like to do.
 
Not too difficult. Just use the WHERE part of the OpenForm method. Something like:
Code:
Docmd.OpenReport "ReportName",,,"[MyDate] BETWEEN #" & nz(txtbox1.value, "") & " # AND #" & nz(txtbox2.value, "") & "#"
Have a look at this too:

http://baldyweb.com/wherecondition.htm
 
Thanks, that should work fine. I also found that in design mode, if you right click on the area of the screen not covered by the report, and click properties, there is a "data" tab for the entire Report which lets you select a record source. You can then use the [...] button to build a query and use form objects in the WHERE clause of the given column, which is what I ended up doing anyhow.
 
Yes, you could do that but it's not going to be dynamic as you must pre-define the criteria, unless you're pointing to the Form's control in the criteria using:

[Forms]![NameOfForm]![ControlName]
 

Users who are viewing this thread

Back
Top Bottom