Referencing Sub Report

  • Thread starter Thread starter Jonathan Parminter
  • Start date Start date
J

Jonathan Parminter

Hi I'm trying to reference a sub-report and get an error
for having an invalid reference. The code I'm using is....

Dim rpt As Form

Set rpt = srptPractitonerDetail.Form
rpt.RecordSource = "qryPractitionerDetailPreview"


The line that fails is Set rpt. I'm sure that it's simple.
But I can't figure it out :-(

Any ideas or suggestions appreciated
Cheers
Jonathan
 
You may have already had the correct declaration:
Dim rpt As Report
Set rpt = srptPractionerDetail.Report

However, the subreport is opened before the main report, so attempting to
reassign the RecordSource of the subreport from the parent report probably
won't be successful.
 
Thanks Allen, 'yes' I had tried declaring as report. But I
noticed that the properties list showed .form not .report,
so I had a go at that.

Your observation that the sub-report is loaded first was
the key for me. I now use a global variable as a switch.

Happy New Year
Cheers
Jonathan
 
Back
Top