Might as well post what I was playing with in the last few minutes (maybe OP doesn't use Environ variables yet). Here's the original code approach but condensed
Code:
Private Sub btnLogin_Click()
Dim strPassword As String
strPassword = DLookup("Password","Users","username = '" & Me.txtUserName & "'")
If Nz(strPassword,0) = 0 Or Me.txtPassword <> strPassword Then
Me.lblIncorrectUserName.Visible = True
Me.txtUserName.BorderColor = RGB(255, 0, 0)
Exit Sub
End If
DoCmd.OpenForm "Home"
DoCmd.Close acForm, Me.Name
End Sub
As long as the lookup won't error based on field/table names it should work, although an error handler wouldn't be a bad idea.