Hello,
I have a custom login page that works
Code:
On Error GoTo ErrorHandler:
If IsNull([txtLogin]) = True Then 'Check if UserName is blank
MsgBox "Please type in your ACF2 or login ID."
Else
'Compare value of txtLogin with the saved Logins in Users table and whether Active is "Yes".
If Me.txtLogin.Value = DLookup("Login", "Users", "[Login]='" & Me.txtLogin.Value & "'") Then
DoCmd.RunMacro "cmdOK"
DoCmd.Close acForm, "Login", acSaveNo
MsgBox "Welcome Back, " & strName, vbOKOnly, "Welcome"
DoCmd.OpenForm "Main", acNormal, "", "", , acNormal
Else
MsgBox "Invalid Login or your Access has been Deactivated. Please try again.", vbOKOnly, "Invalid Password"
intLoginAttempt = intLoginAttempt + 1
txtLogin.SetFocus
End If
End If
This takes the value entered into the txtLogin control on the Login form and does a little dlookup into the Users Table to find if this txtLogin finds a match in the Login column on the Users table.
What I am having difficulty with is trying to add a second criteria to the "If" statement. Not only do I need to match the Login ID, but i have an Active column which has Yes or No beside each user to identify if they are active or not.
I need the "If" statement to look for a matching Login as I have above, plus look to see if that Login has 'Yes" in the Active column as well.
I tried this and It is not working, no debug error, just lets me log in if I have Yes or No.
Code:
If Me.txtLogin.Value = DLookup("Login", "Users", "[Login]='" & Me.txtLogin.Value & "'") And Me.txtLogin.Value = DLookup("Login", "Users", "[Active]= Yes") Then
Suggestions?