How do I pass a value from a Main report to its subreport?
Posted on 2014-08-25
I have a Main report which generates 20 different reports. Within Private Sub Report_OnOpen, a BuildTempTable sub is called with the type of report passed as an input parameter. (See code below). The record source for the Main report is the Temp table. The Main Report is grouped by ReportType. Within the footer section of ReportType, I need a subreport. This subreport's recordsource is set based on the ReportType being processed.
My question: How do I pass the ReportType to the subreport. I have set the Parent/Child connection between the Main/sub report to be ReportType. The subreport has processing within its Report_OnOpen event, dependent on the ReportType.
private Sub BuildTempTableForMainReport(Type as String)
if Type = "A" then
db.execute "INSERT INTO TempTable (ReportType,......) VALUES ('" & Type & ......
elseif Type = "B" then
db.execute "INSERT INTO Temp....
Private Sub MainReport_OnOpen()
'''''''''''' Within subreport
private Sub SubReport_OnOpen()
if ReportType="A" then
me.recordsource = .....
elseif ReportType = "B" then
me.recordsource = ......