Hi I need to passwordprotect two cmd buttons in a form, how do i go about? Like a message box poping up saying insert password if you press the button and then you can (in my case) edit the tables...Very grateful for any suggestions
Firstly,set the enabled property of the command button to No. Next, enter the code below into the On Open event for the form. Private Sub Form_Open(Cancel As Integer)
If CurrentUser() = "yourusername" Then
cmdButtonName.Enabled = True
End If
I found this code really works great!
Private Sub Command75_Click()
If InputBox("Please enter your password", "Authorization needed") = "leisure2" Then
DoCmd.RunMacro "Add"
Else
DoCmd.RunMacro "Macro3"
Exit Sub
End If
I created a blank form with a text box and 2 buttons ok and cancel
here is the code the ok button
Private Sub Command2_Click()
If Text0 = "Password" Then
DoCmd.RunMacro "Macro1"
Else: MsgBox ("Please Renter Correct Password"), vbOKOnly, "Error!", 0, 0
Exit Sub
End If
End Sub
where macro1 does whatever is needed to be protected
then put password in the input mask