Change Password Button with code?

Cassy01

New member
Local time
Today, 08:19
Joined
Jan 2, 2006
Messages
7
Hello All, i am trying to write a macro or use VBA code or something that will allow me to change my password when i click on a command button.

For example i click on the command button and the change password box appears.

Can anybody help?

Thanks
Benn

p.s: Access Novice Here !!
 
Not secure but educational

Heres a very basic way. It’s not secure and can easily be hacked by opening the table and looking at the password. Another way would be to use vba code to put a small file on the hard drive which only you know about. That would have the added bonus that Access could quit if the user tries to put your program on another computer. But thats a little more complex so heres a simple solution you might like to try for openers.

Create a table called Utility, this will have only one record and could be used for various things like NextInvoiceNumber or MyCompanyAddress etc.
Include a field called MyPassword and set its Input Mask to PASSWORD.

Create a form based on the Utility table and add a control called MyPassword.
Open the form once and type in your password.
Go back to design view and hide MyPassword by setting Visible to No.
Put 3 text controls on the form called PWcheck, NewPW and NewConfirm.
These 3 should be Unbound (not linked to any fields in the table).
Set NewPW and NewConfirm Enabled property to No.

Add an Event procedure to the AfterUpdate of PWcheck.
‘if the user knows the existing password, allow him to change it
If Me!PWCheck = Me!MyPassword Then
Me!NewPW.Enabled = True
Me!NewConfirm.Enabled = True
Else
Me!NewPW.Enabled = False
Me!NewConfirm.Enabled = False
MsgBox "Password is incorrect”
End If

Add an event procedure to the afterupdate event of NewConfirm.
‘move the focus so you can clear the text boxes later
DoCmd.GoToControl "PWcheck"
If Me!NewConfirm = Me!NewPW Then
‘update to the new password and tell user
Me!MyPassword = Me!NewPW
MsgBox "Password has been changed”
Else
MsgBox "Failed. Passwords have NOT been changed"
End If
‘clear the text boxes and disable
Me! NewPW = ""
Me! NewConfirm = ""
Me! PWcheck = ""
Me!NewPW.Enabled = False
Me!NewConfirm.Enabled = False

NewPW control does not need a procedure.

I know there will be other ways and you should listen to others as I'm still learning as well.
Mick.
 

Users who are viewing this thread

Back
Top Bottom