Connecting Tech Pros Worldwide Help | Site Map

Error 2455

Keith Wilby
Guest
 
Posts: n/a
#1: Nov 8 '07
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.

Salad
Guest
 
Posts: n/a
#2: Nov 8 '07

re: Error 2455


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.

Tom van Stiphout
Guest
 
Posts: n/a
#3: Nov 8 '07

re: Error 2455


On Thu, 8 Nov 2007 13:41:36 -0000, "Keith Wilby" <here@there.com>
wrote:

Not really sure, but why don't you move this code to the subreport's
Report_Open event?

-Tom.


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.
Keith Wilby
Guest
 
Posts: n/a
#4: Nov 8 '07

re: Error 2455


"Tom van Stiphout" <no.spam.tom7744@cox.netwrote in message
news:bt76j3ljcatr9ldk2hoef0rpjlnd8rv2pq@4ax.com...
Quote:
On Thu, 8 Nov 2007 13:41:36 -0000, "Keith Wilby" <here@there.com>
wrote:
>
Not really sure, but why don't you move this code to the subreport's
Report_Open event?
>
Hi Tom, that's where I originally put it:

Private Sub Report_Open(Cancel As Integer)

Dim strSQL As String

strSQL = "Select * from qsrptCaveat"
If Forms!fdlgPrint!chkInclude = False Then strSQL = strSQL & " Where
[Withdrawn] = 0"
Me.RecordSource = strSQL

End Sub

but I get error 2191, "You can't set the Record Source property in print
preview or after printing has started." Any clues?

Regards,
Keith.

Keith Wilby
Guest
 
Posts: n/a
#5: Nov 8 '07

re: Error 2455


"Keith Wilby" <here@there.comwrote in message
news:47332348$1_1@glkas0286.greenlnk.net...

I think Access is throwing me a bum steer ... I only get that error if there
is one or more record in the sub with the "Withdrawn" flag set, regardless
of the status of the "Include Withdrawn" checkbox on the print dialog. Now
I'm really confused ...

John Mishefske
Guest
 
Posts: n/a
#6: Nov 9 '07

re: Error 2455


Keith Wilby wrote:
Quote:
The report runs fine when I don't try to set its record source at runtime.
What if you add a Me.Requery after setting the record source?

--
'--------------------------
' John Mishefske
' UtterAccess Editor
' 2007 Microsoft Access MVP
'--------------------------
Keith Wilby
Guest
 
Posts: n/a
#7: Nov 9 '07

re: Error 2455


"Keith Wilby" <here@there.comwrote in message
news:47332348$1_1@glkas0286.greenlnk.net...
Quote:
>
but I get error 2191, "You can't set the Record Source property in print
preview or after printing has started." Any clues?
>
Here's the answer if anyone is interested:

I was getting this error when there was more than one record in the *main*
form and needed to suppress setting the *sub's* record source more than
once.

Closed Thread