Solved

Creating a Change Password form on Access 2010

Posted on 2013-10-24
3
3,258 Views
Last Modified: 2013-10-24
I  created a table and query with the following fields (qryUser):

UserID
FName
LName
Employee Name
Password


I have a frmLogin to select Employee and enter the password:

Private Sub Command12_Click()

'Check for correct password
If Me.txtPassword = Me.cboUser.Column(2) Then
    DoCmd.Close acForm, "frmLogin", acSaveNo
    DoCmd.OpenForm "Home"
Else
    MsgBox "Password does not match, please re-enter!", vboOkOnly + vbExclamation
    Me.txtPassword = Null
    Me.txtPassword.SetFocus
End If
End Sub


I created a form for changing the password - button on frmLogin opens frmPasswordReset

Select Employee box and text boxes to enter current password and new password twice.  

Private Sub btnSave_Click()
If Me.pwFirst = Me.pwSecond And Len(Me.pwFirst) & "" > 0 Then
    DoCmd.CloseForm "frmPasswordReset"
    DoCmd.OpenForm "Home"
Else
    MsgBox "New Password entries do not match. Re-enter ." _
        & vbCrLf & "and please try again.", vbCritical, _
        "Re-enter both Passwords."
End If
End Sub



I have most of it, but I am trying to bind employee name selected on frmlogin to employee name/old password on the frmPasswordReset form then get it to change the password on qryUser.  Can you help?
Example.accdb
0
Comment
Question by:NNiicckk
  • 2
3 Comments
 
LVL 61

Assisted Solution

by:mbizup
mbizup earned 500 total points
ID: 39596940
Your code is actually pretty close... you just need to run an update.

Try this behind the Update Button.  It will change the password, but you should work with how and when which forms get opened to make the overall flow better:

Private Sub Update_Click()
Dim s As String
If Me.pwFirst = Me.pwSecond And Len(Me.pwFirst) & "" > 0 Then
    s = "UPDATE tblUser SET Password = '" & Me.pwSecond & "' WHERE UserID = " & Me.cboUser
    CurrentDb.Execute s, dbFailOnError
    DoCmd.Close acForm, Me.Name
    MsgBox "Password Changed!"
Else
    MsgBox "New Password entries do not match. Re-enter ." _
        & vbCrLf & "and please try again.", vbCritical, _
        "Re-enter both Passwords."
End If
End Sub

Open in new window

0
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
ID: 39597010
Here's the db - I added a couple more checks like verifying that the password entered on the reset form matches the one that is stored.

Also look at the code behind the Change Password button on the login form... I revised that (changed the macro to VBA) to open the reset form specifically to the username selected in the combo box.

You still should work with the opening/closing of the various forms, and maybe add a password check to the "Change Password" button on the login form.  There is a lot you can do on your own to make this work more smoothly.
Example.accdb
0
 

Author Closing Comment

by:NNiicckk
ID: 39597115
Great help!
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now