I have forms that need to have data entered but have a field Status (Yes/No) that indicates the data entry is finished. But there are fields that must still be open such as the comment subforms. I am trying to use the tag field to let the form know which fields to lock and the "for each" code to cycle through these.
The form is actually a subform with child subforms of its own. when I try to use this code it locks a test field regardless of whether the status is checked (Closed) or not.
Dim ctrl As control
If Not IsNull(Me.Status.Value) Then
For Each ctrl In Me.Form
'loop thru form to find fields to clear
If InStr(1, ctrl.Tag, "Lock Me" Then
ctrl.Locked = True
End If
Next ctrl
End If
I tried putting an else statement but got this error,
Run Time error438 Object does not support this property or method.
Dim ctrl As control
If Not IsNull(Me.Status.Value) Then
For Each ctrl In Me.Form 'loop thru form to find fields to clear
If InStr(1, ctrl.Tag, "Lock Me" Then
'ctrl = Null
ctrl.Locked = True
Else
ctrl.Locked = False
End If
Next ctrl
End If
Is this doable - if so what is wrong with the code above.
Thanks for your help.
The form is actually a subform with child subforms of its own. when I try to use this code it locks a test field regardless of whether the status is checked (Closed) or not.
Dim ctrl As control
If Not IsNull(Me.Status.Value) Then
For Each ctrl In Me.Form
'loop thru form to find fields to clear
If InStr(1, ctrl.Tag, "Lock Me" Then
ctrl.Locked = True
End If
Next ctrl
End If
I tried putting an else statement but got this error,
Run Time error438 Object does not support this property or method.
Dim ctrl As control
If Not IsNull(Me.Status.Value) Then
For Each ctrl In Me.Form 'loop thru form to find fields to clear
If InStr(1, ctrl.Tag, "Lock Me" Then
'ctrl = Null
ctrl.Locked = True
Else
ctrl.Locked = False
End If
Next ctrl
End If
Is this doable - if so what is wrong with the code above.
Thanks for your help.