Results 1 to 6 of 6
  1. #1
    Coombes1976 is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2018
    Posts
    5

    Help with password reset form

    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

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    In the update SQL you need to concatenate the form reference into the string.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Coombes1976 is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2018
    Posts
    5
    Quote Originally Posted by pbaldy View Post
    In the update SQL you need to concatenate the form reference into the string.
    Sorry would you mind posting an example, I am not very good with VB.

    Many thanks
    Jonathan

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    The example is your DLookup.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Coombes1976 is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2018
    Posts
    5
    Awesome, many thanks all working now

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    Happy to help and welcome to the site!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Need to reset search form.
    By rebfein in forum Forms
    Replies: 2
    Last Post: 04-19-2017, 09:39 AM
  2. Replies: 4
    Last Post: 03-28-2017, 03:10 PM
  3. Replies: 2
    Last Post: 12-24-2012, 10:15 PM
  4. Replies: 1
    Last Post: 06-22-2012, 08:05 AM
  5. Reset imageBox on a form?
    By bosve73 in forum Forms
    Replies: 0
    Last Post: 08-11-2010, 07:16 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums