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
NNiicckkAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
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.
1
NNiicckkAuthor Commented:
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?
0
Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
<<How do I get any update to change the Password = "23456" in the VB Code? >>

 Yes, sorry, I missed the obvious.  You most certainly need a table for your users.  You don't want to be having user names and passwords in code.

 That would mean everytime a user is added or deleted, your app would need to change.

 Far better to do a table like this:

tblUsers
UserID - Autonumber - Primary Key
UserName - Text - Candidate Key
UserPswd - Text
StartupForm - Text

Jim.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

NNiicckkAuthor Commented:
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
0
Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
<<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
0
Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
What version of Access is this DB in?   I can't seem to open it.

Jim.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.