Consulting

Results 1 to 5 of 5

Thread: Solved: Password Protecting - Command Buttons

  1. #1
    VBAX Contributor
    Joined
    Aug 2011
    Posts
    126
    Location

    Solved: Password Protecting - Command Buttons

    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.

  2. #2
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    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:

    [VBA]
    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
    [/VBA]
    Hope that helps,

    Mark

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

  3. #3
    VBAX Contributor
    Joined
    Aug 2011
    Posts
    126
    Location
    Thank you Mark ! That was PERFECT !!!!

  4. #4
    VBAX Contributor
    Joined
    Aug 2011
    Posts
    126
    Location
    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.

    [VBA]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[/VBA]

    Love it ! Thanks Again !

  5. #5
    VBAX Regular
    Joined
    Feb 2012
    Location
    Montreal
    Posts
    6
    Location
    OMG this is awasome!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •