can you password a checkbox?

  • Thread starter Thread starter Vaard
  • Start date Start date
V

Vaard

is there a way so that when a check box is clicked that it
will ask you for a password so if you click cancel or
enter the wrong password, it unchecks the box?

thanks for any help.. much appreciated :)

Vaard
 
In the BeforeUpdate event of the checkbox pop-up a form using the acDialog window mode.
Have a textbox on the form to fill in the password. Place 2 buttons on the form (Ok and
Cancel). When Ok is pressed, hide the form (Me.Visible=False) or if Cancel is pressed,
close the form. Both of these actions will allow the code to continue to run in the
checkbox event. Next, check to see if the form is still open. If it's not, then Cancel was
pressed. If it is, then get the value from the textbox on the form and verify it is the
correct value.

If the form was cancelled or the wrong password was entered, then in the checkbox's event
you would set Cancel=True and Undo the checkbox (Me.chkMyCheckbox.Undo).
 
Code the Check Box Before Update event:

Dim strPass as String
strPass = InputBox("Enter password")
if strPass = "It is I" Then
Else
Cancel = True
End If
 
I used the code Fred wrote, except if you click cancel,
the check stays in the box. i don't understand how to
incorporate the code Wayne provided to have the check box
cleared on a cancel command.

Thanks for the past and any future help.
 
NM, got it working.....

however, is there anyway to masked the input field when it
asks for the password?
 
Not using an Input Box.

Make a new unbound form.
Add a text control.
Set the control's Input Mask property to Password.
Name the control
'txtPass'
Add a Command Button.
Code the button's Click event:
Me.Visible = False
Name this form
'frmPassword'


In the Before Update event:

DoCmd.OpenForm "frmPassword", , , , , acDialog
If forms!frmPassword!txtPass = "Whatever" Then
etc.
Else
etc.
End If
DoCmd.Close acForm, "frmPassword"

The form will open.
Enter the password. Click the command button.
The form will disappear.
The code will continue, then close the password form.
 
Back
Top