Link to home
Start Free TrialLog in
Avatar of NNiicckk
NNiicckk

asked on

Access 2010 Login Form Password Change for Multiple Users

I have created a login form for the multiple users in my database.  Each person has their own "page" when they log in.  I would like to give them the ability to change their password but I do not know how.

Here is a sample of the current login:



Private Sub Command12_Click()

'Check for correct password
UserName.SetFocus
If UserName = "John.Doe" And Password = "12345" Then
    MsgBox "Access Granted!", vbInformation
    DoCmd.Close
    DoCmd.OpenForm "HomeJohnDoe"
ElseIf UserName = "Bill.Smith" And Password = "23456" Then
    MsgBox "Access Granted!", vbInformation
    DoCmd.Close
    DoCmd.OpenForm "HomeBillSmith"
ElseIf UserName = "Jack.Sprat" And Password = "34567" Then
    MsgBox "Access Granted!", vbInformation
    DoCmd.Close
    DoCmd.OpenForm "HomeJackSprat"
Else
    MsgBox "Please re-enter your Username and Password."
End If
End Sub
Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
Flag of United States of America image

At the point of "Access granted", you could ask them if they want to change their password (or force them to do it).   You could also add a button on each of their start pages.

Whatever way, it's simply a form that asks for:

1. Old password
2. New password
3. New password again.

  You give them an "OK" and "Cancel" and if they click "OK", then you:

1. Make sure the old password matches their current password.
2. Both new passwords match
3. Update their old password with the new one.
4. Close the form

I they click cancel, you simply close the form.

Jim.
Avatar of NNiicckk
NNiicckk

ASKER

Jim,

Then, do I need a table that can be updated?

How do I get any update to change the Password = "23456" in the VB Code?
ASKER CERTIFIED SOLUTION
Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Jim,

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 on qryUser.  Can you help?
Example.accdb
<<I created a form for changing the password - button on frmLogin opens frmPasswordReset>>

  Not sure I'd do that there.   Usually, passwords are changed only once you login.  The reason for asking for the old password is to ensure that someone didn't login, walk away, and then someone comes up is able to change the password.

 Your home form might be a better place.

 Looks like you most of the way there though!  I'll download you DB in a bit and have a look.

Jim
What version of Access is this DB in?   I can't seem to open it.

Jim.