I start the printing of a report from a button on a form where certain options are set.
In the report I have a sub-report which acts as a letterhead. Depending on the choices made in the Form , I would like to change the record source of the sub-report (letterhead.)
My code I’m using is:
Dim sqlstr as string
Sqlstr= ”blablabla”
Reports![Mainreport]![subreport].report.recordsource=sqlstr
Or
Me.[subreport].report.recordsource=sqlstr
And this is my problem:
If I put the procedure in the OnOpenEvent of the Main report I get the error message - “invalid reference to a report” (directly translated from German – I’m not sure what the exact error message would be in English)
If I put it on onactivate or onopen of the sub-report I get the error message:-
“You can’t set the recordsource after you’ve started a print job.”
I can’t work out where to put the code!
Does anyone have an idea?
Thanks in advance.
Marion
In the report I have a sub-report which acts as a letterhead. Depending on the choices made in the Form , I would like to change the record source of the sub-report (letterhead.)
My code I’m using is:
Dim sqlstr as string
Sqlstr= ”blablabla”
Reports![Mainreport]![subreport].report.recordsource=sqlstr
Or
Me.[subreport].report.recordsource=sqlstr
And this is my problem:
If I put the procedure in the OnOpenEvent of the Main report I get the error message - “invalid reference to a report” (directly translated from German – I’m not sure what the exact error message would be in English)
If I put it on onactivate or onopen of the sub-report I get the error message:-
“You can’t set the recordsource after you’ve started a print job.”
I can’t work out where to put the code!
Does anyone have an idea?
Thanks in advance.
Marion