Results 1 to 2 of 2

VBA to ask for password before allowing to choose name for password not working

Threaded View

  1. #1
    Forum Contributor
    Join Date
    04-18-2013
    Location
    utah
    MS-Off Ver
    2010
    Posts
    668

    VBA to ask for password before allowing to choose name for password not working

    in the below code I have it set up to ask for a password when an employee chooses there name in a drop down combo box. if the employee enteres wrong password the the cell should say bad password and the cell should show "". This works on the first one I did, but on the other five which i just copied and pasted changing only the combo box# trigger if the employee puts in the wrong password it says wrong password but still enters there name.

    Private Sub cmb4_change()
        Dim pwd As String
        Dim Oops As Boolean
        
        If LockEvent Then Exit Sub
        LockEvent = True
        'Application.EnableEvents = False
        
        pwd = Application.InputBox("Password for " & cmb1.Value & ":", "Enter Password", Type:=2)
        If pwd = "" Then
            cmb1.Value = ""
            LockEvent = False
            'Application.EnableEvents = True
            Exit Sub
        End If
                
        Select Case cmb1.Value
            Case "J. Flack"
                If pwd <> jflack Then Oops = True
            Case "C. Robinson"
                If pwd <> crobinson Then Oops = True
            Case "O. Contreras"
                If pwd <> ocontreras Then Oops = True
            Case "R. Saling"
                If pwd <> rsaling Then Oops = True
            Case "T. Pace"
                If pwd <> tpace Then Oops = True
            Case "A. Curtis"
                If pwd <> acurtis Then Oops = True
            Case Else
                Oops = True
        End Select
         
        If Oops Then
            MsgBox "Bad password"
            cmb1.Value = ""
        End If
        
        LockEvent = False
        'Application.EnableEvents = True
    Last edited by arlu1201; 10-17-2013 at 03:33 AM. Reason: Corrected code tags.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Allowing tick box selection while having the worksheet protected by password.
    By Racetay in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-01-2011, 07:13 PM
  2. Allowing access to password protected spreadsheets
    By DKerr in forum Excel General
    Replies: 3
    Last Post: 06-12-2006, 09:20 AM
  3. Replies: 0
    Last Post: 04-26-2006, 10:25 PM
  4. Replies: 0
    Last Post: 09-06-2005, 03:05 AM
  5. Replies: 0
    Last Post: 09-06-2005, 12:05 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1