Sorting report by date range

  • Follow


I hae a query set up to sort all my data into nice little reports. The only 
problem is a month from now I don't want to have to print everything just to 
get yesterdays report. I would like a query that says only show the records 
for date X through Y, and I would like to use a form to enter the dates, run 
the query then show the report for printing.

Thanks
David
0
Reply Utf 3/19/2008 8:00:04 PM

Add 2 combo boxes to an unbound form (beginning of date range, and end of 
date range).  Enter the following parameter in the date field of your query.
Between [forms]![yourformname]![comboX] and [forms]![yourformname]![comboY]

When you enter dates into your combo boxes, the query will take the values 
entered and restrict the results based on them.



"David" wrote:

> I hae a query set up to sort all my data into nice little reports. The only 
> problem is a month from now I don't want to have to print everything just to 
> get yesterdays report. I would like a query that says only show the records 
> for date X through Y, and I would like to use a form to enter the dates, run 
> the query then show the report for printing.
> 
> Thanks
> David
0
Reply Utf 3/19/2008 8:59:02 PM


On Wed, 19 Mar 2008 13:00:04 -0700, David wrote:

> I hae a query set up to sort all my data into nice little reports. The only 
> problem is a month from now I don't want to have to print everything just to 
> get yesterdays report. I would like a query that says only show the records 
> for date X through Y, and I would like to use a form to enter the dates, run 
> the query then show the report for printing.
> 
> Thanks
> David

Create an unbound form.
Add 2 unbound text controls
Name one control 'StartDate'. 
Name the other control 'EndDate'
Set their format property to any valid date format.

Add a Command Button to the form.
Code the button's click event as follows:

(Note: To write the code, in Form Design View select the command
button. Display the button's property sheet. 
Click on the Event tab. 
On the On Click line, write:

[Event Procedure]

Click on the little button with the 3 dots that appears on that line. 
When the code window opens, the cursor will be flashing between 2
already existing lines of code.
Between those lines, write the following code.)

Me.Visible = False

Close the Code window.

Name this form 'ParamForm'.

In the Query that is the Report's Record Source [DateField] criteria
line write:

Between forms!ParamForm!StartDate and forms!ParamForm!EndDate

Next, code the Report's Open event:
(Using the same method as described above)

DoCmd.OpenForm "ParamForm", , , , , acDialog

Code the report's Close event:

DoCmd.Close acForm, "ParamForm"

When ready to run the report, open the report.
The form will open and wait for the entry of the starting and ending
dates.
Click the command button and then report will run.
When the report closes, it will close the form.
-- 
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
0
Reply fredg 3/19/2008 9:01:04 PM

2 Replies
148 Views

(page loaded in 0.059 seconds)

Similiar Articles:
















7/14/2012 6:13:13 PM


Reply: