Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Creating a Change Password form on Access 2010

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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

688 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