Referencing Sub Report

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
 
A

Allen Browne

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

Jonathan Parminter

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
 

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