Hi, really hoping someone can assist.
I have a split database that requires multiuser logon, I have two forms one to login and another so the user can reset their password. Once the password has been set in the table that stores the credentials I am able to login fine, but when I then reset the password using the password reset form (which updates the field in the table that stores the credentials correctly) I am unable to login with the new password. However I am able to login with the old password, it is like the password is becoming cached and it is picking up the change in the table.
My code is as below...
Login Form
Private Sub OKBtn_Click()
If IsNull(Me.txtUsername) Then
MsgBox "Enter Username", vbInformation, "Username Required"
Me.txtUsername.SetFocus
ElseIf IsNull(Me.txtPassword) Then
MsgBox "Enter Password", vbInformation, "Password Required"
Me.txtPassword.SetFocus
Else
'process the job
If (IsNull(DLookup("UserLogin", "tblUser", "UserLogin ='" & Me.txtUsername.Value & "'"))) Or _
(IsNull(DLookup("UserPassword", "tblUser", "UserPassword ='" & Me.txtPassword.Value & "'"))) Then
MsgBox "Incorrect Login or Password. If you have forgotten your password please contact the database administrator to reset it."
Else
DoCmd.OpenForm "Customer Form"
DoCmd.Close acForm, "Login Form"
End If
End If
End Sub
Code for the password reset form
Private Sub btnChangePw_Click()
Dim PWtocompare As String
PWtocompare = DLookup("UserPassword", "tblUser", "[ID]=" & Me.txtLoginID.Value)
If txtOldPW = PWtocompare Then
If txtNewPW = txtNewPW2 Then
Me.txtNewPW.SetFocus
Dim strSQL As String
strSQL = "UPDATE tblUser SET UserPassword = '" & Me.txtNewPW.Text & "' WHERE ID = txtLoginID"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
MsgBox "Password Changed"
DoCmd.OpenForm "Login Form"
DoCmd.Close acForm, "PasswordChange"
Else
MsgBox "Passwords do not match, please re-enter your new password", vbOKOnly, "Passwords do not match"
End If
Else
MsgBox "Current password does not match records. Please enter your current password again", vbOKOnly, "Incorrect Password"
End If
End Sub
I hope this makes sense as I have spent several hours trying to get it to work. It is driving me mad!
Many thanks
Jonathan