Access JumpStart 2.0 | Blog

A Rapid Development Framework for Microsoft Access

One of my clients was occasionally getting a 2455 error in Access:

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

What was happening in this case was that the user had minimized Access and then closed Access using the icon on the taskbar, by right clicking and choosing the close option.

When the user reopened the database, it would open in a tiny box in the upper left corner of the screen with only the Access icon, maximize, and close buttons showing like this:

And then my app would try to load subforms and subreports on the main page. I discovered that the attempt to reference the form or report contained in the control is what caused the issue. This code in particular inside a function I was using to make my main code simpler:

Private Function GetSubReportControl() As Access.subform
    Set GetSubReportControl = Forms("frmENWappMenu_BB").Controls("HomeScreen_Main").Report.Controls(SUBREPORT_CONTROL)
End Function

The portion throwing the error was the “.Report” portion. Turns out you get this error when trying to reference the form or report inside of a subreport control if the detail section of the form is hidden.

The detail section of the form could be just one pixel high and the object would be returned and the error would not be thrown.

So as I was playing with the height needed to correct this problem, that is how I discovered that it was the detail section.

In my case I also have a Header and Footer section on my form and Access shows those first, until you have their heights maxed out before it starts displaying the Detail section.

Now I am using the Timer on the Form to trigger the loading of the subform in this function here:

Private Sub frm_Timer()
    frm.TimerInterval = 0
    If frm.InsideHeight < frm.Section(acHeader).Height + frm.Section(acFooter).Height Then GoTo Exit_Timer
    If FormIsVisible Then RaiseEvent HomeScreenInForeground Else RaiseEvent HomeScreenNotInForeground
Exit_Timer:
End Sub

In this code you can see that I am using an If statement to compare the total Form inside height (which includes all displayed sections) with the sum of the Footer height and the Header height. This is the magic number at which my Detail section starts to be displayed. By adding that if statement, I bypass triggering the events that try to reload those sub reports.

This was quite a tricky problem to solve as the error message is completely unhelpful and the error is occurring only under certain circumstances. I hope this can help someone down the road stuck in a similar situation.