Connecting Tech Pros Worldwide Forums | Help | Site Map

Referring to a subreport (Error 2455)

Kirsty Ryder
Guest
 
Posts: n/a
#1: Nov 13 '05
Hi,

I have a Report with a subreport, and I want to assign a value to the
control source of a control on the subreport depending on the value
given by the user in a separate form. Based on advice from the online
help and from other posts in this group, I wrote the following code
which is called on the On Open even of the main report. I have tried
several variations on this, which always result in the same error
message-

Run-time error 2455 'You entered an expression that has an invalid
reference to the property Form/Report.'

I have checked that the subreport name I am referring to is the
control name that appears in the main report and not the actual name
of the subreport.

THE OFFENDING CODE:
[Reports]![Insufficient Crew Report]![SubReport4 Basingstoke And
Deane].Report!TotalPercentOnRun.ControlSource = tempvalue

I hope that this makes sense to someone, I've run out of ideas!
Thanks in advance,
Kirsty

Steve Jorgensen
Guest
 
Posts: n/a
#2: Nov 13 '05

re: Referring to a subreport (Error 2455)


You can only set a report object's RecordSource property at run-time from
within the execution of its OnOpen event. Access initializes subreports
before parent reports, so the subreport's OnOpen event has already completed
by the time the main report's OnOpen event tries to set it.

What you have to do is have the Subreport set its own Recordsource property
from its own OnOpen event handler.

On 16 Dec 2004 06:54:46 -0800, kl_ryder@hotmail.com (Kirsty Ryder) wrote:
[color=blue]
>Hi,
>
>I have a Report with a subreport, and I want to assign a value to the
>control source of a control on the subreport depending on the value
>given by the user in a separate form. Based on advice from the online
>help and from other posts in this group, I wrote the following code
>which is called on the On Open even of the main report. I have tried
>several variations on this, which always result in the same error
>message-
>
>Run-time error 2455 'You entered an expression that has an invalid
>reference to the property Form/Report.'
>
>I have checked that the subreport name I am referring to is the
>control name that appears in the main report and not the actual name
>of the subreport.
>
>THE OFFENDING CODE:
>[Reports]![Insufficient Crew Report]![SubReport4 Basingstoke And
>Deane].Report!TotalPercentOnRun.ControlSource = tempvalue
>
>I hope that this makes sense to someone, I've run out of ideas!
>Thanks in advance,
>Kirsty[/color]

Closed Thread


Similar Microsoft Access / VBA bytes