Password Form

Dina01

Registered User.
Local time
Today, 00:40
Joined
Apr 24, 2002
Messages
87
Hello,
I created a logIn form for my database and I am working on a form that the user can change his password or reset it....

my table is named "tblUsersÈ and it looks like this...

LastName FirstName User Password EmployeeNo

ABBRUZZESE SAMMY abruzess ***** 11529
ABEL JEAN RONALD abeljea ***** 10477
ABRAHAM CKYRCK.B abrahac ***** 15089

Then in my form I have 4 texbox
User
UserName
Password
PasswordConf

What I would like to do is when I click on the CmdChange, the password has to change and update the table, but if ever the user doesn't type in the same password when he types the password confirmation then he should get an error message stating that the password don't match....

Can anyone tell me how to do this...

This is my code
*************

Private Sub CmdChange_Click()

On Error GoTo Err_cmdChange_Click

If Me![Password] = Me![PasswordConf] Then

MsgBox ("IDENTICAL -- Please update")

DoCmd.OpenForm "Ecran_PCP_form"
DoCmd.Close acForm, "frmLogin"
Else
MsgBox ("Mots de passe ne sont pas identique")
Me![PasswordConf] = ""
Me![User].SetFocus
Me![PasswordConf].SetFocus
DoCmd.CancelEvent
End If

Exit_cmdChange_Click:
Exit Sub

Err_cmdChange_Click:
MsgBox Err.description
Resume Exit_cmdChange_Click

End Sub

Everything works fine but I don't know how to UPDATE the table to erase the old password, and update with the new one.
 
Last edited:
Dina,

I would approach this form a little differently. I would have the two text boxes (I'll call them tbxPassword and tbxPasswordConf) be unbound, i.e., not tied to the Password field in tblUsers.

I would place a third text box on the form, call it tbxNewPassword, make its recordsource be the Password field in tblUsers, and set its Visible property to No. (Keeping this text box away from the user will ensure that if the user makes errors in typing a new password, it does not destroy the old one.)

When the user clicks the Change command button you can compare tbxPassword with tbxPasswordConf, and if they are the same, set tbxNewPassword to the value of either of them. If you set the new password into tbxNewPassword text box, with recordsource the Password field in your table, it will replace the old one, and will be saved when the form is closed.

(I would use the expression
If(Nz(Me.tbxPassword,"") <> Nz(Me.tbxPasswordconf,"")) then
to do the comparison, to avoid dealing with Nulls.)

In case the new passwords do not match, it would be a good security practice to clear both tbxPassword and tbxPasswordConf, and set the focus to tbxPassword before exiting from the subroutine. That will make the user re-enter both, in case she/he typed the wrong password into tbxPassword and the correct password into tbxPasswordConf.

You might also consider checking to see that the new password is not null, and is of some minimum length, before allowing the change to proceed. If you check this at the beginning of the code you can avoid using the Nz functions in the If statement comparison.

Bonne chance!

Jim
 
Thank You JIM
 

Users who are viewing this thread

Back
Top Bottom