Have you step debugged? If control is blank it is likely Null. Cannot compare anything to Null - it only returns Null, not True or False. So it doesn't matter if you use = or <>, when comparing to Null condition never evaluates as True and code inside If block never runs.
Don't process if values not provided. Consider:
Code:
Private Sub btnLogin_Click()
Dim rs As Recordset
Me.lblWrongUN.Visible = False
Me.lblWrongPas.Visible = False
If Not IsNull(Me.TxtUserName) And Not IsNull(Me.TxtPassword) Then
Set rs = CurrentDb.OpenRecordset("SELECT * FROM tblUserPass WHERE UserName='" & Me.TxtUserName & "'", dbOpenSnapshot, dbReadOnly)
If rs.EOF Then
Me.lblWrongUN.Visible = True
Me.TxtUserName.SetFocus
ElseIf rs!Password <> Me.TxtPassword Then
Me.lblWrongPas.Visible = True
Me.TxtPassword.SetFocus
Else
DoCmd.OpenForm "AllTrackMainPage"
DoCmd.Close acForm, Me.Name
End If
Else
MsgBox "Must enter " & IIf(IsNull(Me.TxtUserName), "Username", "Password")
End If
End Sub