View Full Version : Liking a checkbox to lock down a subform.


Migratorymoab
03-05-2002, 09:37 AM
I am currently setting up a db, and I am at a point where a record might need to be locked down if a certain checkbox is activated. Does anyone out there know how to accomplish this?

BukHix
03-05-2002, 09:54 AM
This should work for you:


Private Sub chkMyCheckBox_Click()
If chkMyCheckBox = True Then
frmFormName.Enabled = True
Else
frmFormName.Enabled = False
End If
End Sub

bauer
03-05-2002, 10:29 AM
I personally have a form where I did this by locking all of the controls, and call this from the Form_Current Event, this way when you go to that record, it will know whether to lock or not

Sub Locking
On Error goto Err_Locking

For Each ctlControl In frmYours.Controls
ctlControl.Locked = chkLock
Next
'so you can still uncheck this
chkLock.Locked = False
Exit_Locking:
Exit Sub

Err_Locking:
'if control doesn't lock eg. lables etc.
If Err = 438 Then
Resume Next
Else
MsgBox Err.Description
Resume Exit_Locking
End If