Reputation: 1692
Yesterday, a form/subform that worked well for me for a long time suddenly started throwing Error 2455: You entered an expression that has an invalid reference to the property Form/Report.
Below is my diagnosis of the problem. It feels like a bug.
My question is: Have any of you ever seen this? If you are interested, could you try to duplicate the problem, and let me know what you find?
The Problem:
After lots of experimentation, I narrowed it down to this:
My Workaround: Always ensure that at least part of the form's Detail section is visible in the SubForm control. Either:
Can you duplicate this? This is weird, so I would like some independent confirmation of this problem. So, please, if you have a little time, try these steps:
My 'grandchild' forms have no RecordSource when loaded. The recordsource is set in code after the parent/child forms load.
Please, indicate the version of Access you are running, and what results you get. I'm running Access Version 14.0.7128.5000, which seems pretty up-to-date.
Upvotes: 7
Views: 9281
Reputation: 181
For my case, the subform should have its .SourceObject = ""
until the linked form is ready, then set it as .SourceObject = "linked_form_name"
, but somehow (because of other errors), I see it already populated with content in design view !
So setting it again as .SourceObject = ""
in Design View solved the issue for me.
Upvotes: 1
Reputation: 11
The solution I employed was to use the form timer, to ensure that the report and sub reports had all loaded first. I was modifying the filter on sub reports, and getting the 2455 error until I added the timer.
Upvotes: 1
Reputation: 1
I know this question is old but I was able to solve this problem by making sure the form's Detail
property was set to True
. I have an If
statement checking for a condition:
If Me.Detail.Visible = False Then Me.Detail.Visible = True.
Upvotes: 0
Reputation: 81
Even though this is an old thread and the answer for OP was most certainly something else, I share this in hope it will help shed some light for others who have stumbeld on the "Error 2455: You entered an expression that has an invalid reference to the property Form/Report". Which may be pretty confusing and occure quite far from the actual cause of the error.
Happened to me today on Access 2016. While making some changes to a project, one of the forms started suddenly throwing Error 2455 in its Form_Load() event containing a single line of code:
Private Sub Form_Load()
Set mevtReferenceToSubform = Me.frmASubform.Form
End Sub
As pointed out in stackoverflow.com/questions/5023631/... in the comments to the question:
"Controls bound to the recordsource of the parent form (including subforms with LinkChild/LinkMaster properties) do not load when there are no records."
Apparently the same goes for an unbound subform aswell. The subforms '.Form' property will not be accessible from its parent form if the parent form's RecordSource query does not return any records!
In my case the culprit turned out to be a TempVar declaration which I had replaced with another solution, elswhere in the code. But had failed to notice that the removed TempVar was even used by the now failing parent form's query, which didn't return any results...
Upvotes: 8
Reputation: 53
I think this has to do with the Form's CurrentView property. I had a similar case and simply avoided the case when the Form's CurrentView was 1 ("Form" view). This solution worked for me:
If Me.CurrentView <> 1 Then
Me.sfrWPCN.Form.RecordSource = strSQL
End If
Upvotes: 1