Invalid reference to subform form property (ms Access 2007)

I am using a technique similar to the one in Remou's answer to this question to manipulate the controls on the subform . Works fine as long as the record set of the parent form has at least one record. If the parent form has no entries, I get:

Error 2455, "You entered an expression that has an invalid reference to the Form / Report property."

An error occurred while trying to recursively call. The following is a simplified version of the code (I turned off error handling and a couple more cases, including Else). This code lives in the module and is called from the load event of most forms in my application:

Public Sub LockUnlockForm(frmLoad As Form)

Dim ctl As Control

    For Each ctl In frmLoad.Controls
        With ctl
            Select Case .ControlType
                Case acTextBox, acComboBox, acCheckBox
                    .Locked = Not gblnAuthorized
                Case acSubform
                    LockUnlockForm .Form  '<--- this line errors
            End Select
        End With
    Next

End Sub

, , , - ( gblnAuthorized True , ). , LockUnlockForm? ?

+2
1

form recordset For , > 0.

, , . . HansUp, !

+9

Source: https://habr.com/ru/post/1584331/


All Articles