Update db password

lemon_balm

Registered User.
Local time
Today, 12:26
Joined
Feb 7, 2006
Messages
65
Hi,

Can someone please have a look at the below code and see where I'm going wrong.
The code works and I have tested it with message boxes to prove that but the new password isn't being returned to the table.




Option Compare Database
Option Explicit
Dim pwcount As Integer

Private Sub btnchange_Click()
Dim uname As String
Dim opword As String
Dim npword1 As String
Dim npword2 As String
Dim resetpw As String

uname = Me!txtuser.Value
opword = Me!txtoldp.Value
npword1 = Me!txtnewp1.Value
npword2 = Me!txtnewp2.Value
resetpw = DLookup("password", "username", "[userID] ='" & uname & "'")

If opword = DLookup("Password", "username", "[userID] ='" & uname & "'") And npword1 = npword2 Then
resetpw = npword2
Else
MsgBox "Please try again", , "Details Incorrect"
pwcount = pwcount + 1
Me!txtoldp = Null
Me!txtnewp1 = Null
Me!txtnewp2 = Null
End If
If pwcount = 3 Then
MsgBox "please contact the administrator", , "Too many attempts"
DoCmd.Close
End If

End Sub


Table Name: Username
Table fields: Password, UserID, ID
Form Name: Changepassword
Form fields: txtuser, txtoldp, txtnewp1, txtnewp2

Regards

Jason
 
After the password has been changed and verified you need to run an update query (using the new password as athe parameter)
 
Superb

Nice one Smart.

That's just what I needed to make things work.

I removed the resetpw variable as it was now redundant and created an update query to pass the information back to my table.

Many thanks

Jason
 

Users who are viewing this thread

Back
Top Bottom