PDA

View Full Version : Solved: Password Protecting - Command Buttons



Rlb53
02-17-2012, 06:59 PM
Hello All !

My workbook is totally controlled by the user selecting one of several Command Buttons on the Front Page for a particular task. From that point they will be able to recieve, select and enter data that followup Userforms allow them to.

However, I need to allow some of the data to be updated but do not want this ability to permitted by all.

How may I "Password Protect" a single Command Button on the Front Page to allow permitted users to update / change data ?

Thank you for you help.

GTO
02-18-2012, 12:56 AM
Hi there,

Presuming you are using activex controls, you could insist that a password is entered into a textbox before the button really does anything.

For instance, with a button and textbox both default named:

In the Worksheet's Module:


Option Explicit

Private Sub CommandButton1_Click()
If Me.TextBox1.Value = "My Password" Then
MsgBox "Call the userform or whatever...", 0, vbNullString
Me.TextBox1.Value = vbNullString
End If
End Sub

Hope that helps,

Mark

PS - use the textbox's PasswordChar property to obscure the password entered.

Rlb53
02-18-2012, 01:29 AM
Thank you Mark ! That was PERFECT !!!!

Rlb53
02-18-2012, 01:35 AM
I was so excited I hit the send button before I meant to.

I made a little change... modified the operation of the command as noted.
which gets rid of the Click.

Option Explicit
Private Sub Passwordform_Change()
If Me.Passwordform.Value = "12345678" Then
MsgBox "You Have Permission to Enter", 0, vbNullString
Me.Passwordform.Value = vbNullString
Unload Me
UpdateVendorForm.Show
End If
End Sub

Love it ! Thanks Again !

Maradona_10
02-18-2012, 11:55 AM
OMG this is awasome!!!