Connecting Tech Pros Worldwide Help | Site Map

Error 2455

 
LinkBack Thread Tools Search this Thread
  #1  
Old November 8th, 2007, 12:45 PM
Keith Wilby
Guest
 
Posts: n/a
Default Error 2455

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, 01:45 PM
Salad
Guest
 
Posts: n/a
Default 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, 01:45 PM
Tom van Stiphout
Guest
 
Posts: n/a
Default 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, 02:15 PM
Keith Wilby
Guest
 
Posts: n/a
Default 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, 02:25 PM
Keith Wilby
Guest
 
Posts: n/a
Default 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, 12:25 AM
John Mishefske
Guest
 
Posts: n/a
Default 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, 08:05 AM
Keith Wilby
Guest
 
Posts: n/a
Default 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.

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.