Locking form if check box is selected

jonman03

Registered User.
Local time
Today, 09:47
Joined
Nov 5, 2009
Messages
31
Hey everyone,

This one seems pretty easy, but can't figure it out. :(

I have a check box on a form. How can I create an If statement that "If the check box is checked, then lock the form so data can't be changed" And only allow the form data to be edited if the box is unchecked.

Something like:

If Me.Checkbox = "checked" Then Lock form?

I just don't know the syntax.

Thank you!
 
In the Checkbox_AfterUpdate and the Form_Current events
Code:
If Me.Checkbox = -1 Then
  Me.AllowEdits = False
 Else
  Me.AllowEdits = True
 End If
 
Ok, that seemed to lock it down when I check it.

But one more request, any way to allow users to uncheck it? Since its locked now, can't uncheck it to reallow editing.

Sounds weird, but a pretty specific form I'm trying to work on... Thank you!
 
Add the code to AllowEdits with a command button.

Me.AllowEdits = True
Me.Checkbox = 0
 
Not only sounds weird, it is weird! What is the point in locking the record if the users can merely unlock it at will?

If you only want an authorized person to be able to edit the record after it is locked down, what I usually do is use the OnClick event of a label on the form to set AllowEdits back to True. Most non-developers don't realize that labels have a Click event and woudn't think of clicking on one.
Code:
Private Sub YourLabelName_Click()
  Me.AllowEdits = True
End Sub
 

Users who are viewing this thread

Back
Top Bottom