Change Password form

Turbo910

Registered User.
Local time
Today, 00:11
Joined
Nov 8, 2009
Messages
43
Hi guys ive got a login form and im trying to put together a change password form also.
now what i have already is a form with combo box for the username (combo0) a text box (oldPassword), and two more text boxes for (newPassword) and (verifyPassword). I think its all quite self explanitary for what each one does but just in case. What i want is for the user so select their username(combo0) and type in thier old password in (oldPassword), then type in a new password in (newPassword) and verify the new password in (verifyPassword). I also have a command button, but from here on out i don't know where to go, i have little knowledge in sql or vba but im willing to learn.

I do need the help pretty fast.

Thanks very much in advance guys :)
 
So, first thing you will need to do is see if the old password entered is correct... you can do this with a dlookup

Something like

Then check the 2 new passwords against eachother to make sure they match.

then finally use an update query to put the new password in the person's record.

Code:
If Me.txtPass.Value = DLookup("EmployeeUserPass", "tbl_Employee",  "[EmployeeUserName]= """ & txtName & """") Or Me.txtPass.Value =  DLookup("AdminPass", "tbl_Employee", "[EmployeeUserName]= """ &  txtName & """") Then 
if (me.newpassword1 <> me.newpassword2)
messagebox "New password does not match"
exit sub;
else
...Run your update query...
end if
 
Hey thanks very much for your reply, and the code looks like it could work, but i know very little about VBA code, or any code for that, so could you do me a huge favour and replace your values with mine that i gave you in my first post and also write out the script for running my query so that i just have tot replace the name of my query?

Id be very gratefull

Kind regards
 
Just to add to what rainman said, because you're comparing passwords there's the likelihood you want to test for different cases as well. If that's the case, use the StrComp() function (with the right arguments) to match cases.
 
I have a further issue on the same subject, I can't update the new password!

Using a change password form, I can check the current password, I can check that the two new passwords match but I can't add the new password to the table! So a pretty big omission in functionality! This stuff below currently works and is the way I've gone about it, but for reference purposes:

Code:
 Private Sub CheckCurrentPassword_Click()
Password.Value = Me.UserNameBox.Column(2)
If OriginalPassword = Me.UserNameBox.Column(2) Then
MsgBox ("Password Is Verified")
passwordverified = True
Else
MsgBox ("Password Is Incorrect")
passwordverified = False
End If
End Sub

Code:
  Private Sub BtnConfirmPassword_Click()
If txtNewPassword <> txtNewPassword2 Then
MsgBox ("passwords do not match")
Exit Sub
End If

If passwordverified = True Then
me!FrmChangePassword.Usernamebox.column(2) = Password.value
MsgBox ("Congratulations, your password has now been updated")
docmd.close
Else
MsgBox ("Password Incorrect, please enter the correct password")
End If

NB: The aforementioned Password textbox basically holds the value for the adjacent column in my "username" combobox, which holds:

UsergroupID;UserGroupName;Password

-----

There must be a simple way to update the password!
Code:
me!FrmChangePassword.Usernamebox.column(2) = Password.value
doesn't work :(
 
Last edited:
you need to do an update query to change their password
 
Not sure how to do an update query! Sorry, forgot to mention that little important note!
 
You would want to change this
Code:
If passwordverified = True Then
me!FrmChangePassword.Usernamebox.column(2) = Password.value
MsgBox ("Congratulations, your password has now been updated")
docmd.close
Else
MsgBox ("Password Incorrect, please enter the correct password")
End If
to something like
Code:
If passwordverified = True Then
CurrentDB.Execute "UPDATE tablename set password = yourpasswordvalue where employee = your employee"
MsgBox ("Congratulations, your password has now been updated")
docmd.close
Else
MsgBox ("Password Incorrect, please enter the correct password")
End If

Changing the values in the query to match your information
 
looks top dollar! Cheers! Really appreciate the help! However I have a little niggle:

Code:
If passwordverified = True Then
CurrentDb.Execute "UPDATE tblsecurity set password = TxtNewPassword where me.cbousernamebox.column(1) = usergroupname"
MsgBox ("Congratulations, your password has now been updated")
DoCmd.Close
Else
MsgBox ("Password Incorrect, please enter the correct password")
end If

It says the combobox I use for selecting the user group is an undefined function?

I've found this:

Code:
CurrentDb.Execute _
"UPDATE Table1 SET [TextField] = MyCustomFunction([textField])"

and I can see I'm missing the "mycustomfunction" but have no real idea what mycustomfunction is! or what it should be?
 
Last edited:

Users who are viewing this thread

Back
Top Bottom