Hi everyone,
I was wondering if I can solicit some ideas because I am sure I am going about this incorrectly.
I have a subform in a form. The subform is in datasheet view.
In the "Form_Current" routine, I am trying to lock the controls if a record exists, but unlock the controls if it is a new record.
Here is what I have:
When I get to the records, I get this error:
"Runtime error '438':"
"Object doesn't support this property or method"
It's referring to the "ctl.locked =" statement.
If I call each control by name, the code works like a charm
Ex:
Calling each control by name is fine on the smaller forms, but I have a subform with many controls and if possible I just want to use a blanket statement and loop through the controls instead of naming each of them.
Anyone have any ideas or can point me in the right direction?
Thanks,
Craig
I was wondering if I can solicit some ideas because I am sure I am going about this incorrectly.
I have a subform in a form. The subform is in datasheet view.
In the "Form_Current" routine, I am trying to lock the controls if a record exists, but unlock the controls if it is a new record.
Here is what I have:
Code:
Dim frm as Form
Dim ctl As Control
Set frm = Me.Form
If Me.NewRecord = True Then
For Each ctl In frm
ctl.Locked = False
Next
Else
For Each ctl In frm
ctl.Locked = False
Next
End If
Set frm = Nothing
"Runtime error '438':"
"Object doesn't support this property or method"
It's referring to the "ctl.locked =" statement.
If I call each control by name, the code works like a charm
Ex:
Code:
If Me.NewRecord = True Then
txt_AcquisitionType.Locked = False
txt_AcquisitionDesc.Locked = False
Else
txt_AcquisitionType.Locked = True
txt_AcquisitionDesc.Locked = True
End If
Anyone have any ideas or can point me in the right direction?
Thanks,
Craig