I followed the tutorial from XIPooo on creating a classic Log in form, below is the code I wrote:
Option Compare Database
Option Explicit
Private Sub btnLogin_Click()
Dim rs As Recordset
Set rs = CurrentDb.OpenRecordset("LogIn_tbl", dbOpenSnapshot, dbReadOnly)
rs.FindFirst "UserName='" & Me.txtUserName & "'"
If rs.NoMatch = True Then
Me.lblwronguser.Visible = True
Me.txtUserName.SetFocus
Exit Sub
End If
Me.lblwronguser.Visible = False
If rs!Password <> Me.txtPassword Then
Me.lblwrongpassword.Visible = True
Me.txtPassword.SetFocus
Exit Sub
End If
Me.lblwrongpassword.Visible = False
DoCmd.Close acForm, "LogIn_frm"
DoCmd.OpenForm "Home_frm"
End Sub
The problem I have when I enter a wrong user name it works fine, however when I hit enter or click the Log In Button after entering the correct user name it skips the password entry and closes the form without a password. The tutorial was shown for 2013 I am running 2010 is there a difference in programming?
Or I have I coded the second part of the routine wrong???