sub reports

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.
 
A

Allen Browne

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.
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top