Solved

Creating a Change Password form on Access 2010

Posted on 2013-10-24
3
3,881 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
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 …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

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