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
Bookmarks