I am trying to create a login form where the username and password input match the data on a sheet. I tried to code for if either the username or password is wrong, it will show a msgbox and clear the input to redo. But when I tested that function, nothing happened. Picture here
Code here
Private Sub login_Click()
Dim x, a As Double
a = WorksheetFunction.CountA(Range("A:A"))
If untb.Value = "" Then
MsgBox ("Enter the username"), vbOKOnly
ElseIf passtb.Value = "" Then
MsgBox ("Enter the password"), vbOKOnly
ElseIf untb.Value <> "" And passtb.Value <> "" Then
For x = 1 To a
If untb.Value = Cells(x, 2) And passtb.Value = Cells(x, 3) Then
Unload Me
MsgBox ("Welcome to Great Wines :)"), vbOKOnly
order.show
End If
Next x
Else
MsgBox ("Invalid username or password!"), vbOKOnly
untb.Value = ""
passtb.Value = ""
untb.SetFocus
End If
End Sub
activesheet
?login_Click
sub even called properly? Have you tried setting break points?