Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2012

    Unanswered: Error in Change Password Form

    Hi everyone!

    When I select a username from the combo box and set a new password for the same user then it changes the password for all users in the table Users, which means it is not changing one user password but it changes all users passwords.

    Can anyone look at it and solve it please.

    Private Sub ChangePassword_Click()

    Dim strsql As String

    'Check to see if data is entered into the UserName combo box
    If IsNull(Me.cboCurrentEmployee) Or Me.cboCurrentEmployee = "" Then
    MsgBox "You must enter a User Name.", vbOKOnly, "Program"
    Exit Sub
    End If

    'Check to see if data is entered into the old password box
    If IsNull(Me.oldpassword) Or Me.oldpassword = "" Then
    MsgBox "You must enter a Password.", vbOKOnly, "Program"
    Exit Sub
    End If

    'Check value of password in table Users to see if this matches value chosen in combo box
    If Me.oldpassword.Value = DLookup("Password", "Users", "[Last Name]=""" & Me.cboCurrentEmployee.Value & """") Then

    'Change the Old Password in to New password
    strsql = "UPDATE Users SET password=" & "'" & Me.NewPassword.Value & "' WHERE [Last Name]='" & Me.cboCurrentEmployee.Value & "'"
    DoCmd.SetWarnings False
    DoCmd****nSQL (strsql)
    DoCmd.SetWarnings True
    Debug.Print (strsql)
    MsgBox "Password has been changed", vbInformation, "Password Changed"
    MsgBox "The Old Password doesnot match", vbInformation, "Type Correct Old Password"

    Exit Sub

    MsgBox Err.Description
    'Resume Exit_ChangePassword_Click

    End If

    End Sub

  2. #2
    Join Date
    Apr 2004
    Derbyshire, UK
    Provided Answers: 2

    If you want to update ALL the records in the 'Users' table then you do not have a WHERE clause in the UPDATe query/sql as this will limit the records updated!?

    I am a little puzzled as to why you would want to do this, unless this is purly for the database administrator!


  3. #3
    Join Date
    Nov 2004
    out on a limb
    Provided Answers: 59
    Can we see the value of strsql
    ...set a breakpoint step through th code till strsql is set then copy and paste here
    I'd rather be riding on the Tiger 800 or the Norton

  4. #4
    Join Date
    Aug 2012
    Let me clarify:

    This form is a help tool for users to change their passwords.

    User A must be able to change his/her password with this form. But the problem is when User A sets his/her new password to "test" the form automatically changes all other users passwords to "test" and that is not good.

    With this form User A must be able to only change his/her password not that of other Users.

    I think there is something wrong with the SQL statement but I cannot find it. I have tried many other ways but the problem remains the same.

  5. #5
    Join Date
    Aug 2012
    I don't know what is going on but the probem is solved.

    I just exported the form and table to a blank database and then imported to the original database after which it is now working fine. Welcome to Microsoft!

    Thread solved there has to be done nothing with the code.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts