Keith Wilby wrote:
Quote:
Why do I get this error when I run this code from a report's open event?
>
strSQL = "Select * from qsrptCaveat"
If Forms!fdlgPrint!chkInclude = False Then strSQL = strSQL & " Where
[Withdrawn] = 0"
Me.subCaveat.Report.RecordSource = strSQL
>
"subCaveat" is the object name (not the report name) of the sub-report
on the report. The error message is:
>
"You entered an expression that has an invalid reference to the property
Form/Report."
>
The report runs fine when I don't try to set its record source at runtime.
>
Many thanks.
>
Keith.
It looks OK. If you break in the code, what happens if you did a
msgbox "Source is " & Me.subCaveat.Report.RecordSource
prior to setting the recordsource?
Maybe you can do the setting in the subreport instead of the main report.
Or perhaps you can use the same recordsource but set a filter on it from
the main report...depending on if you can access the subreport.