Hi, I have a login form and a table of users. In the table of users there is a column called TempPFlag that is set to '1' if the password has been reset.
I have the following code and want it to first check if the username and password entered matches what is in the table but also check if they need to reset their password - check if Tbl_users.TempPFlag = '1' then open form frm_reset
I have the following code and want it to first check if the username and password entered matches what is in the table but also check if they need to reset their password - check if Tbl_users.TempPFlag = '1' then open form frm_reset
Code:
Private Sub cmd_login_Click()
If IsNull(Me.txtloginID) Then
MsgBox "Error", vbInformation, "Please enter a username"
Me.txtloginID.SetFocus
ElseIf IsNull(Me.txtPassword) Then
MsgBox "Error", vbInformation, "Please enter a password"
Me.txtPassword.SetFocus
Else
Credentials.UserName = Me.txtloginID.Value
If DLookup("Password", "tbl_users", "UserName = '" & Credentials.UserName & "'") = Me.txtPassword Then
Credentials.UserId = DLookup("ID", "tbl_users", "UserName = '" & Credentials.UserName & "'")
Credentials.AccessLvlID = DLookup("AccessLvl", "tbl_users", "UserName = '" & Credentials.UserName & "'")
Select Case Credentials.AccessLvlID
Case 1
DoCmd.OpenForm "frm_1"
Case 2
DoCmd.OpenForm "frm_2"
Case 3
MsgBox "Your Account Has Been Deactivated. Please contact a super user."
Case Else
DoCmd.OpenForm "frm_loginform"
End Select
If Me.txtPassword = "password" Then DoCmd.OpenForm "frm_userprofile" 'vlad moved the closing here to leave the user profile open
DoCmd.Close acForm, Me.Name
Else
MsgBox "Incorrect Login or Password"
End If
End If
End Sub