try the following code, as
Private Sub isProtectRecord()
On Error Resume Next
Dim ctrl As Object
For Each ctrl In Me.Controls
ctrl.Enabled = Not Me!Completed
Next ctrl
If Me!Completed.Enabled = False Then Me!Completed.Enabled = True
End Sub
note that the code "toggles" the Enabled property all controls on the form,
according to the value of the Completed checkbox - then it goes back and
enables the Completed checkbox specifically, if it was disabled. if you have
other specific control(s) on your form (such as certain command buttons, for
example) that should NOT be disabled at any time, then add an If statement
for each one, to make sure it is always enabled.
call the code from the form's Current event procedure, and also from the
Completed checkbox's Click event procedure, as
Private Sub Completed_Click()
isProtectRecord
End Sub
Private Sub Form_Current()
isProtectRecord
End Sub
hth
Nightman said:
Tina,
Thank you for your post.
This is what I want.
I have a form called "ORDERS" and the form has many fields and a subform.
then there is a checkbox called "Completed". this check box is bound to the
a field in database.
If the check box is checked, the user should not be able to edit any of the
fields in the current record. unchecking the checkbox should enable the
fields to editable again.
I also need to show the fields in the form looks "disabled in gray"
Every time the user move to disabled record in the form, I want the record
to be un-editable.
regards
Nathan