The code uses late binding to open a DAO recordset object. Don't understand why that is failing. I just tested the original code in Access 2010 and it works. However, I don't have Access 2007 to test with.
Consider not even using recordset object:
Code:
Private Sub BtnLogin_Click()
If IsNull(DLookup("UserName", "tbl1Employees", "UserName='" & Me.txtUserName & "'")) Then
Me.lblWrongUser.Visible = True
Me.txtUserName.SetFocus
Exit Sub
End If
Me.lblWrongUser.Visible = False
If Nz(DLookup("Password", "tbl1Employees", "UserName='" & Me.txtUserName & "'"),"") <> Me.txtPassword Then
Me.lblWrongPass.Visible = True
Me.txtPassword.SetFocus
Exit Sub
End If
Me.lblWrongPass.Visible = False
DoCmd.OpenForm "frmDialog"
DoCmd.Close acForm, Me.Name
End Sub
Be aware Access is not case sensitive by default. So ABC123$ equals abc123$.
Also, please post lengthy code within CODE tags to retain indentation and readability. Use # button on the editor toolbar.