Reputation: 77
I have a question on checkboxes in acess 2003
I have 4 checkboxes on my form and one of these boxes, i want to restrict so only users supplied with the correct password eg (report1) can check that box. I have a small textbox to the side of the checkbox labelled manager password.
I am not sure how to set this validation in access. I have right-clicked on the check box, gone to properties and seen the validation rule but not sure where to go from there. I have an idea of what my VB code will be if applicable and I am including that if it helps
Code Snippet If txtpassword.text = "report1" then closedsftleader.yes = true else msgbox.show "Management Password is incorrect, please try again"
END IF
Not even sure if this code would work but its an idea. Please help when you can. Thank you.
Upvotes: 2
Views: 2552
Reputation: 91376
Have you considered locking or disabling this particular checkbox? For example:
Private Sub Form_Current()
Me.closedsftleader.Enabled = (Me.txtpassword = "Report1")
End Sub
Private Sub txtpassword_AfterUpdate()
Me.closedsftleader.Enabled = (Me.txtpassword = "Report1")
End Sub
Disabling like this is simple for your user to understand, rather that a checkbox that seems impossible to click, furthermore, it will be easy enough to change this to refer to a global variable or user name.
I generally set tag properties for controls, which allows me to hide or enable controls in batches, according to the user and / or password.
Upvotes: 2
Reputation: 4171
You can handle the OnClick event of the checkbox and not allow a change if the textbox doesn't have the correct password.
Upvotes: 1
Reputation: 4440
You want to add an event on the text box (I believe it's the "changed" event) and then enable/disable the textbox based on the contents of the text box.
As a side note, this is an odd design for protecting contents of a form. You may want to consider forcing users to log in to your Access app.
Upvotes: 1