View Full Version : How can I Password protect a cmd button in a form....HELP?


OliviaS
08-07-2001, 01:13 AM
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

DJN
08-07-2001, 06:01 AM
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

End Sub
Hope this helps.

OliviaS
08-07-2001, 11:54 PM
Thanks for the tip but I'm sorry to say that it didn't work....Nothing happens when I open the form...?

OliviaS
08-08-2001, 02:09 AM
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


End Sub

Orangatuan
05-03-2005, 02:21 AM
Is there some way to edit the layout of the password form??

still_rookie
05-03-2005, 12:23 PM
yeah if can't atleast make the input in astrix :confused:

Orangatuan
05-06-2005, 02:24 AM
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

still_rookie
05-06-2005, 05:21 AM
does it have astix when typing the password /?

Mile-O
05-06-2005, 05:25 AM
then put password in the input mask

does it have astix when typing the password /?

Why don't you just follow the advice and see?

debo33
05-06-2005, 07:56 AM
OliveS,

How do you incrept that password the command button in your previous response?

debo

Tim L
05-06-2005, 08:03 AM
Debo,

have you searched the forum for encryption and or password encryption and or protecting passwords? There is a lot of information about this around.

Tim