Connecting Tech Pros Worldwide Help | Site Map

Error 2455

  #1  
Old November 8th, 2007, 01:45 PM
Keith Wilby
Guest
 
Posts: n/a
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.

  #2  
Old November 8th, 2007, 02:45 PM
Salad
Guest
 
Posts: n/a

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.

  #3  
Old November 8th, 2007, 02:45 PM
Tom van Stiphout
Guest
 
Posts: n/a

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.
  #4  
Old November 8th, 2007, 03:15 PM
Keith Wilby
Guest
 
Posts: n/a

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.

  #5  
Old November 8th, 2007, 03:25 PM
Keith Wilby
Guest
 
Posts: n/a

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

  #6  
Old November 9th, 2007, 01:25 AM
John Mishefske
Guest
 
Posts: n/a

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
'--------------------------
  #7  
Old November 9th, 2007, 09:05 AM
Keith Wilby
Guest
 
Posts: n/a

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
In case you ever get an error 2455 salad answers 0 December 9th, 2005 07:46 PM
Stuck with Run Time Error 2455 Robert McGregor answers 0 November 13th, 2005 07:28 AM
Referring to a subreport (Error 2455) Kirsty Ryder answers 1 November 13th, 2005 06:24 AM
RunTime Error 2455 in Access 2000 Vladislav Moltchanov answers 0 November 12th, 2005 10:39 PM
RunTime Error 2455 in Access 2000 Vladislav Moltchanov answers 0 November 12th, 2005 10:12 PM