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:
- I had a form that worked perfectly standalone, setting recordsources for each of its subforms
- But the form failed when it was put in a subform control, throwing error 2455 for every subform when trying to set the SubForm.Form.RecordSource property (but again, only when the form itself was a subform)
After lots of experimentation, I narrowed it down to this:
- The SubForm control was too short to show the form's Detail section. Only the Header was visible.
- Since the form's detail was not visible, Access silently disabled all of the subforms under the form!!!
My Workaround: Always ensure that at least part of the form's Detail section is visible in the SubForm control. Either:
- Increase the height of the SubForm control
- Move controls from the form Header to the detail, and make the Header shorter, or invisible, so only the detail shows.
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:
- Make a form with:
- A subform control that holds a grandchild form
- A header section, height 0.5 inches
- Add this form as a child in a parent subform control
- The working case:
- Set the parent's subform height to .6 inches, so the child's detail section is visible
- In code, refer to the child's subform.Form.RecordSource property (the grandchild).
- Expectation: no error
- The failing case:
- Now, set the parent subform height to .4 inches, so the detail is NOT visible
- Rerun the code that touches the child's subform.Form.RecordSource property.
- Expectation: Runtime Error 2455
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.