Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Creating a Change Password form on Access 2010

Posted on 2013-10-24
3
Medium Priority
?
4,600 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 2000 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 2000 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

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

885 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