change password

saadtanvir93

New member
Local time
Tomorrow, 01:13
Joined
Sep 27, 2018
Messages
5
please help

Private Sub Command7_Click()
If IsNull(Me.Text0) Then
MsgBox "please enter oldpassword", vbininformation, "warning"
Me.Text0.SetFocus
ElseIf IsNull(Me.Text2) Then
MsgBox "please enter Password", vbininformation, "warning"
Me.Text2.SetFocus
Else
'process the job
If (IsNull(DLookup("password", "tbluser", "password='" & Me.Text0.Value & "'"))) Then
MsgBox "incorrect password", vbininformation, "warning"
Else
If (Me.Text2 = Me.Text4) Then
CurrentDb.Execute "UPDATE tbluser " _
& "Set Password = 'Me.text2'" _
& "Where Userid = 'Me.text8';"
MsgBox ("Your password has now been updated")
End If
End If
End If
End Sub



in this code text0 is previous password
text2 in the new password and
text8 is the username

the code runs fine but does not update the value in the table
 
please use the code tags to preserve formatting (highlight the text and click on the # button. If you can't be bothered to do that, please don't be surprised if others won't bother to try to understand the code.

You will also find the code becomes much more readable if you give variables meaningful names


with regards your issue I'm interpreting that you have a problem with this bit of code

CurrentDb.Execute "UPDATE tbluser " _
& "Set Password = 'Me.text2'" _
& "Where Userid = 'Me.text8';"

Recommend to assign the code to a string so you can debug.print it and see what you have actually created. You can also copy and paste the sql to a new query to see how it runs.

I can tell you that you are missing a space before WHERE
 
Hi,


Is the table getting updated at all? If so, are the fields getting updated to contain "Me.text2" instead of what's in text2? If so, try concatenating the control references into your SQL, which you will notice if you follow CJ's suggestion of printing the SQL statement in the Immediate Window. For example:


"Set Password='" & Me.Text2 & "' "


Hope it helps...
 

Users who are viewing this thread

Back
Top Bottom