How can I Password protect a cmd button in a form....HELP?

OliviaS

Registered User.
Local time
Today, 16:13
Joined
Jul 19, 2001
Messages
16
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

End Sub
Hope this helps.
 
Thanks for the tip but I'm sorry to say that it didn't work....Nothing happens when I open the form...?
 
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
 
Fine But....

Is there some way to edit the layout of the password form??
 
heres what i done

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
 
OliveS,

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

debo
 
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
 

Users who are viewing this thread

Back
Top Bottom