Msg box error

GordonM

New Member
Joined
Jun 30, 2017
Messages
25
Hi guys,
need a little help on this one.

I have a userform its for a login page (Username and password) i have a few if and if not on it, but when i run the code it still gives me a message box (Wrong username) but only on the second user (Gordon) Im sure its something small.

Code:
If TextBox1 = "Gordon" And TextBox2 = "123" Then
Sheet1.Activate
Ufdairy.Show
End If
Unload UserForm2
If TextBox1 = "Collin" And TextBox2 = "1234" Then
Sheet1.Activate
Ufdairy.Show
End If
Unload UserForm2

If Not TextBox1 = ("Collin") Or TextBox1 = ("Gordon") Then
MsgBox ("Wrong User Name")
Exit Sub
End If


If Not TextBox2 = "1234" Or TextBox2 = "123" Then
MsgBox ("Wrong Password, Please Try Again")
Exit Sub
End If



End Sub
 
This is going to solve any possible problem
Code:
If TextBox1 = "Gordon" Then
    If TextBox2 = "123" Then
        Sheet1.Activate
        Ufdairy.Show
        Unload Me
    Else
        MsgBox ("Wrong Password, Please Try Again")
    End If
ElseIf TextBox1 = "Collin" Then
    If TextBox2 = "1234" Then
        Sheet1.Activate
        Ufdairy.Show
        Unload Me
    Else
        MsgBox ("Wrong Password, Please Try Again")
    End If
Else
    MsgBox ("Wrong User Name")
End If
 
Upvote 0

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

Forum statistics

Threads
1,217,380
Messages
6,136,226
Members
450,000
Latest member
jgp19

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top