How can I re-use the same subreport within a larger report and pass a variable to each iteration of the subreport?
Posted on 2014-08-08
I have a Report (ReportA) that contains the following code within the Report_Open event:
'gCode is a Global variable
if gCode = "A" then
me.RecordSource = "SELECT A1 AS Field1, A2 AS Field2 " & _
elseif gCode = "B" then
me.RecordSource = "SELECT B1 AS Field1, B2 AS Field2 " & _
elseif gCode = "C" then
me.RecordSource = "SELECT C1 AS Field1, C2 AS Field2 " & _
gCode is set on FormA. The user selects a radial button and then clicks a 'View Report' button.
My issue: I need to print all 3 iterations of this report (with gCode set to A, and then B, and then C) and have a cumulative counter at the bottom of each page. So, if each report is 5 pages long, along with Page 1 of 5, Page 2 of 5, etc. appearing on the page for each of the 3 reports, I also need to display an overall counter Page 1 of 15, Page 2 of 15 as well.
So as not to have to make 3 copies of this report and then force the value of gCode within each of the 3 copies, how can I have 3 iterations of this ReportA (as a subreport) on a Main report and pass each iteration the gCode value?