Question Change Password Form (1 Viewer)

saqibawr

Registered User.
Local time
Today, 13:16
Joined
Oct 3, 2008
Messages
27
How to create change password from of existing users in access without creating new table.

If a database having several users. They logon to database through login form & a user wants to cannge his existing password.

This from contains User Name, Old Password, New Password, Verify New Password.

what will be the vb coding for that form can anyone help?
 
Last edited:

MR_G

Registered User.
Local time
Today, 02:16
Joined
Oct 14, 2008
Messages
35
How are your passwords stored? In a hidden table of some sort?
 

saqibawr

Registered User.
Local time
Today, 13:16
Joined
Oct 3, 2008
Messages
27
Here is what i m talking about.
 

Attachments

  • Pwd Chng.zip
    17.1 KB · Views: 172

MR_G

Registered User.
Local time
Today, 02:16
Joined
Oct 14, 2008
Messages
35
I am new to this site and NO EXPERT! by any means, but I just did something similar at work so it may help you:

On your CHANGE PASS form:
include a hidden listbox [lstbox_PASSCHECK]

lstbox_PASSCHECK will have a rowsource of a Query [qry_FIND_PASSWORD]

that looks for the password with the username box [txtUsername] as a criteria. Assuming that no one user has multiple passwords, the [qryFIND_PASSWORD] should return only 1 value. Now make sure you remember to update that Query after [txtUsername] is changed. (under the afterupdate section of the events property you can just write me.lstbox_PASSCHECK.Requery). This makes sure that you get the appropriate password everytime you change user names.

Also set lstbox_PASSCHECK value to lstbox_PASSCHECK.ItemData(0). This puts the first value of your query into the value of the lstbox. You can also create a new textbox (also hidden) and just pass it the value lstbox_PASSCHECK.ItemData(0)

I used the second method, but I think both should work.

Now that you have all that done!

You need to write an update query that will change the value in the Login table with the username [txtUsername], as a criteria. It will update to the value of the user inputed NEWPASSWORD [txtPass1]. If you don't know the path, just use the "builder" function on the "update to" section of the update query. We will call that query, "Update_Password"

Lastly!

You will write code that is a basic If... Then statement saying:

If me.pwdLastSet=me.lstbox_PASSCHECK.value AND me.txtPass1=txtPass2.Text Then
DoCmd.OpenQuery "Update_Password"
MsgBox "Your password has been changed!"
' here you want to clear you textboxes, listboxes, etc. me.txtbox.value = Null
DoCmd.Close acForm "Change Pass"
Else
MsgBox "Your password is incorrect."
me.pwdLastSet.SetFocus ' This just puts the user back to the OldPassword txtbox
End If


Don't forget to clear the values for the lstbox_PASSCHECK and the username, oldpassword, newpassword, etc.

This is probably a hack way at doing it, and I am sure there are cleaner better ways out there, but this one worked for me. Experiment with it and let me know if it helps at all!

(perhaps you should use userID instead of username because of multiple identical names? or maybe a combination of both? Sorry, maybe you have already done that and I didn't see. Just a thought.)

Hope this all helps!

MR_G
 

saqibawr

Registered User.
Local time
Today, 13:16
Joined
Oct 3, 2008
Messages
27
Can you apply this code to the form in database that i uploaded and create the Query as well and upload it for me because i want to see weather it works or not.
 

MR_G

Registered User.
Local time
Today, 02:16
Joined
Oct 14, 2008
Messages
35
I would recommend working through it yourself to see how it all fits together. The basic structure is just to load a copy of the password somewhere on the form, but hide it, then use an If... a=b...Then statement to see if the old password matches the new one, then run an update query that changes your table. That format will work. I have a couple forms that use that format at work and they are all up and running fine. Like I said, a seasoned pro on here will probably poke holes in my logic and rightfully so, but if you just need something that works, this will do it. Sorry I can't load it on to the form myself right now, but the fiance is coming soon and she will kill me if she sees I am working on databases again :) god only knows what she might do if she finds out it's not even mine! If you get stuck, let me know.

MR_G
 

Users who are viewing this thread

Top Bottom