As far as I know, printing or previewing a report are practically the same for Access, so I guess both following lines will pass the value from the main report to the subreport:
DoCmd.OpenReport "ReportName" 'this will print the report
DoCmd.OpenReport "ReportName", acPreview 'this will display it on the screen
If you mean changing the recordsource, this is only possible in the Open event of the report, so you can't do it 'while' printing or previewing.
However, you can filter the existing records after you have already opened the report, but this has effect only in Preview mode, because if you print it directly, the report is closed immediately after having been rendered to the printer.
Have I missed the point???
I hope you understand more than I do from what I wrote here...
You are correct in mentioning the record source of the sub-report. I was attempting to change it on the fly (great in theory – failed in practice) based upon the year as the printing progressed. The SQL code was valid but it was a “no-no” to change the record source while the printing was in progress. Another thought was to send arguments to the sub-report and let it do what I wanted it to do based upon the arguments.
My workaround was to make two labels and place the contents of the query into the labels, which is a poor solution since the labels (unlike text boxes) can’t grow. It worked but it wasn’t the elegant solution that I had hoped to find.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.