Pass paramaters from one report to another

yoavb

New member
Local time
Today, 13:05
Joined
Dec 27, 2011
Messages
4
Hi,
I've been stuck with this issue for quite a while so help will really be appreciated...

I have a report based on a query that shows machine utilization for a list of machines. Before loading, the report prompts dialog boxes to enter the parameters for the query: sDate and eDate (start & end dates respectively).
Each record in that report has a command button that opens another report that specifies machine errors for the single machine selected.
The new report is based on a query that receives the parameters sDate, eDate and mCode (dates and machine code). I'm trying to send the parameters from the first report to the second one so that when I open the new report, I won't have to enter anything.
I've tried different methods to send the paramaters by editing the command button's click event in vba.
startdate, enddate, machinecode are invisible textbox fields in the first report with the values I need.

Code:
DoCmd.OpenReport "rpt_MachineBreaks", acViewReport, , "sDate=" & Me.startdate & " AND eDate=" & Me.enddate & 
" AND mCode=" & Me.machinecode
But the dialog boxes prompt me to enter sDate, eDate and mCode

Another approach was to modify the query parameters for the new report using QueryDefs
Code:
Dim db As Database
Dim qry As QueryDef
 
Set db = CurrentDb
Set qry = db.QueryDefs("qry_singleMachineBreaks")
 
qry.Parameters("sDate") = Me.startdate
qry.Parameters("eDate") = Me.enddate
qry.Parameters("mCode") = Me.machinecode
 
DoCmd.OpenReport "rpt_singleMachineBreaks", acViewReport
Again, the dialog boxes prompt to enter sDate, eDate and mCode...

Help Please!!!
 
Last edited:
Hi Gizmo,
I considered using a form that would essentialy "save" the parameters, but this would only help me with the dates. I still need the machine number passed on, and it's only selected after the first report is opened, by clicking the specific command button related to the machine record.
Thanks
 

Users who are viewing this thread

Back
Top Bottom