Results 1 to 5 of 5

userform button code needs attention to work correctly

Threaded View

  1. #1
    Registered User
    Join Date
    12-15-2012
    Location
    Pensacola, Florida
    MS-Off Ver
    Excel 2010
    Posts
    3

    userform button code needs attention to work correctly

    I have a userform that opens up, prior to my employees using a worksheet form. This userform has a combobox for their name & a text box for their password. A command button that enables them to enter the worksheet area. The code worked fine until i changed from a textbox to a combobox. At first they were typing their name into a textbox =username, but i added a combobox instead to quicken the process. Now I get "Please Try Again", which you will see in this code or my uploaded file.

    Thanks, Hope Someone Can Help!!


    Private Sub UserForm_Initialize()
    'Populate Employee combo box.
    Dim rngEmployee As Range
    Dim ws As Worksheet
    Set ws = Worksheets("Setup")
    For Each rngEmployee In ws.Range("Employee")
    UserForm1.ComboBox1.AddItem rngEmployee.Value
    Next rngEmployee
    End Sub

    Private Sub CommandButton1_Click()
    Dim username, password As String

    username = ComboBox1.Text
    password = TextBox2.Text

    If username = "Ramsey" And password = "admin" Then
    MsgBox "Thank You", vbInformation
    Unload Me ' unload this form

    End If

    If username = "Ronnie" And password = "admin" Then
    MsgBox "Thank You", vbInformation
    Unload Me ' unload this form

    End If

    If username = "Doug" And password = "admin" Then
    MsgBox "Thank You", vbInformation
    Unload Me ' unload this form

    End If

    If username = "Fish" And password = "admin" Then
    MsgBox "Thank You", vbInformation
    Unload Me ' unload this form

    End If

    If username = "Willie" And password = "admin" Then
    MsgBox "Thank You", vbInformation
    Unload Me ' unload this form

    Else
    MsgBox "Please Try Again", vbCritical

    End If
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

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