PDA

View Full Version : Solved: Error 2455 - invalid reference to the property Form/Report



snorkyller
03-01-2011, 09:30 AM
I sometimes get the following error:
Error 2455 - invalid reference to the property Form/Report
On the this line:
[Forms]![FormName]![SubFormName].Form.RecordSource = sql_query

It never occurs when the form isn't opened in design mode when I run it. When it is, it usually works fine. The error occurs only sometimes (and it's impossible to know when). When it does, if I stop the execution, then run the form again, the error will be triggered every time! But if I close the design mode, then run the form again, everything's fine (???)

If you have any idea, please let me know...
Thank you

snorkyller
03-01-2011, 02:10 PM
One solution.... :

I got around this problem like this: Instead of modifying directly the .RecordSource property from another form, like below...
[Forms]![FormName]![SubFormName].Form.Recordsource = sql_query

...I modify it from inside the form itself, by replacing the above line with these:
RefreshRecordSource = True 'global variable
[Forms]![FormName]![SubFormName].Requery

The Form_Current sub is instantly called, in which I added these lines:
If RefreshRecordSource then
Me.Recordsource = sql_query
End if

I had an other similar bug, which is also definitely an Access bug:
The below line doesn't call at all the Form_Current event when you run the form while it's opened in design mode. When all the forms are closed, everything is fine.
[Forms]![FormName]![SubFormName].Requery

Stupid bugs like these make me lose my time.... :shifty:
I hope this message could make you save some of yours...