Limiting a Report to a Date Range

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like to print a report for a specific date range. I have several
subreports which are all in my main report, which is called rptMainReport. I
would like to print this main report for only a specific date range. I have
tried various different ways to try and do this, none of which have worked.
I have tried setting up queries, and basing my subreports off of the queries,
setting up a form so that I would only have to enter the date once. I can't
seem to make this work, but there must be some way for me to accomplish this.

Any new ideas or suggestions would be greatly appreciated! Thank you
 
I would like to print a report for a specific date range. I have several
subreports which are all in my main report, which is called rptMainReport. I
would like to print this main report for only a specific date range. I have
tried various different ways to try and do this, none of which have worked.
I have tried setting up queries, and basing my subreports off of the queries,
setting up a form so that I would only have to enter the date once. I can't
seem to make this work, but there must be some way for me to accomplish this.

Any new ideas or suggestions would be greatly appreciated! Thank you

Create an unbound form. Add 2 Text Controls.
Name one StartDate and the 2nd EndDate.

Add a command button.
Code the button's click event:

Me.Visible = False

Name this form 'ParamForm'.

In each query, in it's Date field's criteria line, write:
Between forms!ParamForm!StartDate AND forms!ParamForm!EndDate

Next, code the main report's Open event:
DoCmd.OpenForm "ParamForm", , , , , acDialog

Code the main report's Close event:
DoCmd.Close acForm, "ParamForm"

When ready to run the report, open the report. The form will display
and wait for the entry of the dates. Click the command button and the
report will run without need for any further parameter entries. When
the report closes, it will close the form.
 
I tried this and it worked....thank you!

The only question I have is when I open up the report first, and then the
form prompts me to enter the dates, but after enterting the dates the report
will not open. But if I open the form first, and enter the dates the report
is perfect. I coded everything as you stated below. Any reason why this
would happen? Thanks much.
 
I tried this and it worked....thank you!

The only question I have is when I open up the report first, and then the
form prompts me to enter the dates, but after enterting the dates the report
will not open. But if I open the form first, and enter the dates the report
is perfect. I coded everything as you stated below. Any reason why this
would happen? Thanks much.

What you are stating is not possible if you have done it all
correctly.

Queries are the record source for the reports, is that correct?

1) The report is already open when it opens the form.
2) The form is opened by the report in Dialog mode, meaning that
everything stops until you enter the dates and click the command
button.
3) When you click the command button the form is made not visible and
the report data is shown on the screen (or prints out).
4) You did something incorrectly, perhaps by combining my method with
what you had already done or coded before. Are you sure you set the
command button on the form code to Me.Visible = False (and not the
Report)?
5) As a test, make a new sample report, using my method, and see what
you get.
 
Yep, I did have some coding in there from before when I was trying different
things...I deleted it and now the report works perfectly....thanks so much
for your help!
 
I thought your suggestion of creating and unbound form etc. would work for
me, but when I try to open my main form I get an error message "Access can't
find the Macro 'DoCmd' " but ParaForm opens and when I click on the Command
Button after entering the dates I get the error message "the object doesn't
contain the Automation object 'Me' ". Could you give me some sugestions as to
what could be wrong?

JK
 
Back
Top