sub reports

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

Guest

I'm trying to use a sub-report 'template' on several reports. Each time a
report is generated, the sub-report will have a different record source. I
can't seem to get this correct. I have the following on the Open command of
the main report

Dim rs As subreport
Set rs = Me.RecordSource = "qry_#_global"

thanks for any help you can provide.
 
That's not going to work.

Access opens the subreport *before* the main report. Once its Open event
runs, you're stuck. It is therefore impractical to modify the RecordSource
of the subreport for each instance that it needs to be placed on the main
report.

You will need to find another approach for whatever it is you need to
achieve.
 
I found the answer:
In the Subreport you would create an OPEN Event that looks like. So
depending on the main report that opens this sub report the record source
will change accordingly.

Select Case Me.Parent.Name
Case "Report2"
Me.RecordSource = "ABC"
Case "Report3"
Me.RecordSource = "XYZ"
End Select
 
Back
Top