HomeGrowth
Technical User
I have this code on the Form_Current( ) of the main form.
Dim ctl As Control
If Me.ynoLocked = -1 Then 'Check for the locked is checked.
'go thgouh the subform, and lock this up.
For Each ctl In Me.Controls
If ctl.ControlType = acSubform Then
If ctl.Form.Tag = "L" Then 'skip this subform that doesn't have L tag
ctl.Form.AllowEdits = False
ctl.Form.AllowAdditions = False
End If
End If
Next
Else
'go thgouh the subform, and UNLOCK this up.
For Each ctl In Me.Controls
If ctl.ControlType = acSubform Then
If ctl.Form.Tag = "L" Then 'skip this subform that doesn't have L tag
ctl.Form.AllowEdits = True
ctl.Form.AllowAdditions = True
End If
End If
Next
End If
I got Run-Time error ‘2455’: You entered an expression that has an invalid reference to the property Form/Report.
I created a button on the main form using the above codes, this button works fine to AllowEdits and AllowAdditions for all subforms (that has the tag property = ‘L”).
So, my question: How do I get the subforms prevent edit and addition if the Locked field is true on the main form from a record to another. Thanks!
Dim ctl As Control
If Me.ynoLocked = -1 Then 'Check for the locked is checked.
'go thgouh the subform, and lock this up.
For Each ctl In Me.Controls
If ctl.ControlType = acSubform Then
If ctl.Form.Tag = "L" Then 'skip this subform that doesn't have L tag
ctl.Form.AllowEdits = False
ctl.Form.AllowAdditions = False
End If
End If
Next
Else
'go thgouh the subform, and UNLOCK this up.
For Each ctl In Me.Controls
If ctl.ControlType = acSubform Then
If ctl.Form.Tag = "L" Then 'skip this subform that doesn't have L tag
ctl.Form.AllowEdits = True
ctl.Form.AllowAdditions = True
End If
End If
Next
End If
I got Run-Time error ‘2455’: You entered an expression that has an invalid reference to the property Form/Report.
I created a button on the main form using the above codes, this button works fine to AllowEdits and AllowAdditions for all subforms (that has the tag property = ‘L”).
So, my question: How do I get the subforms prevent edit and addition if the Locked field is true on the main form from a record to another. Thanks!