Passing Parameters to Reports for Printing

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

Guest

I am working on modifiying an existing Report and I am a little rusty in
Access.

I have a report that "On Open" is running a Make Table Query. The make
table query prompts for a Start Date and an End Date.

My report then uses the table created by this query to join with data in
other tables.

My problem is I want to Print the Start Date and the End Date on this report
without it prompting the user to enter the dates a second time. I assume my
problem is that the report is running 2 separate queries (the make table
query & then the 2nd pulling from that data) and that the report annot
transfer the dates from one query to the other????

Can this be done? Is there a way I can pass these as variables from one
query to the other? Or is there an easier way to do this?

Any help is greaty appreciated.
 
Kathy,
Try creating a "dialog" form with a StartDate and End Date unbound field.
The form would open and prompt the user for fill in the StartDate and
EndDate.
A button on the form called RunReport when clicked, would run the make
table query using the form Date values, then open the report using those
same form Date values.
hth
Al Camp
 
I need a little more assistance.

I have created a form to capture the dates and to run the report. However,
I am not sure how to run the report and pass those dates into the existing
report.
On the form I have my date fields (dteStart & dteEnd). I have used these
field names within my existing report criteria.

I am using the following code to run the report.

-----------------------
Private Sub cmdRunHandler_Click()

Dim stDocName As String

Msgbox "Test - Start date is " & dteStart
stDocName = "Handler Summary"
DoCmd.OpenReport stDocName, acPreview

End Sub
-----------------------
The form & code are successfully capturing the dates; however when the
report starts to open, I am prompted to enter the "dteStart" again.

Thanks for any advice.
Kathy
 
Create a pop-up form named PFrmParameters with two textboxes named DteStart
and DteEnd. Add a command button to the form and put the following code in
the Click event of the button:
Me.Visible = False

Base your report on a query and set the criteria of your date field using:
Forms!PFrmParameters!DteStart and Forms!PFrmParameters!DteEnd

Put the following code in the Open event of the report:
DoCmd.OpenForm :PFrmParameters",,,,,acDialog
...... If you want to include the Start and End dates in the report title,
use this code:
Me.Caption = "My Report is for the period " & Forms!PFrmParameters!DteStart
_
& " To " & Forms!PFrmParameters!DteEnd
DoCmd.Close acForm, "PFrmParameters"
 
I am still having difficulties.

I have successfully created a form to capture my dates. My problem is I am
dealing with 2 queries. The first is a "Make-Table" query which my second
query uses to link data to. I have not been able to figure out how to run
the Make-table query thru code & pass the dates to it.

I can successfully run a report thru code & pass the dates to it which have
been setup in the reports criteria. The problem is it doesn't appear that
you can create a report from a Make-Table query. Therefore I do not now how
to run this query while passing the dates.

Any more ideas?
 
Back
Top