donkey9972
Registered User.
- Local time
- Today, 09:12
- Joined
- May 18, 2008
- Messages
- 54
Okay I have a login form and when the temporary password is set to "Password" for a new user, the new user logs in and then it should direct them to change their password upon first login. So on the login form I have this code set on the login button:
When a user logs in with user name and password if their password is set to anything other than "Password" it displays their first name correctly on the following form. This code is on that following form and it works really well:
I also have a button on that form if the user wants to change their password and the First name carries over without an issue. However, my problem is when their password is set to "Password" requiring a first time login password change it is not displaying. This is the code on that password change form:
Code:
Private Sub cmd_login_Click()
Dim FIRST_NAME As Variant, access_level As Variant, user As Variant
Dim TempPass As String
If Trim(Me.txt_username.Value & vbNullString) = vbNullString Then
MsgBox prompt:="Username required.", buttons:=vbExclamation, title:="Information"
Me.txt_username.SetFocus
Exit Sub
End If
If Trim(Me.txt_password.Value & vbNullString) = vbNullString Then
MsgBox prompt:="Password required.", buttons:=vbExclamation, title:="Information"
Me.txt_password.SetFocus
Exit Sub
End If
' RETREIVE FROM SAVED QUERY
' ASSUMES EVERY USER GIVEN A NON-NULL ACCESS LEVEL
FIRST_NAME = DLookup("FirstName", "tbl_login", "UserName = '" & Me.txt_username & "' and password = '" & Me.txt_password & "'")
access_level = DLookup("access_level", "tbl_login", "UserName = '" & Me.txt_username & "' and password = '" & Me.txt_password & "'")
If IsNull(FIRST_NAME) = True Then
MsgBox prompt:="Incorrect username/password. Try again.", buttons:=vbCritical, title:="Information"
Me.txt_username.SetFocus
Else
MsgBox prompt:="Welcome, " & FIRST_NAME & ".", buttons:=vbOKOnly, title:="to the QAE System"
TempPass = DLookup("[Password]", "tbl_Login", "UserName='" & Me.txt_username.Value & "'")
If (TempPass = "Password") Then
DoCmd.OpenForm "frm_ChangePassword", acNormal, "", "", , acWindowNormal
GoTo Done
End If
'save the first_name and access_level to Tempvars
TempVars("First_Name") = FIRST_NAME
TempVars("Access_Level") = access_level
TempVars("user") = Me.txt_username.Value
' CONDITIONALLY OPEN FORMS
Select Case access_level
Case "Admin"
DoCmd.OpenForm "frm_Admin"
DoCmd.Close acForm, "frm_login", acSaveNo
Case "User"
DoCmd.OpenForm "frm_User"
DoCmd.Close acForm, "frm_login", acSaveNo
End Select
End If
Done:
DoCmd.Close acForm, "frm_login", acSaveNo
End Sub
When a user logs in with user name and password if their password is set to anything other than "Password" it displays their first name correctly on the following form. This code is on that following form and it works really well:
Code:
Private Sub Form_Load()
Me.Text325 = TempVars("First_Name").Value & ""
End Sub
I also have a button on that form if the user wants to change their password and the First name carries over without an issue. However, my problem is when their password is set to "Password" requiring a first time login password change it is not displaying. This is the code on that password change form:
Code:
Private Sub Form_Load()
Me.Text337 = TempVars("First_Name").Value & ""
End Sub