Hello
OK, I’ve just ‘rolled out’ a database, for the first time I’ve used the Access Security wizard to secure the system, well the obvious has happened. One of the users has forgotten what password they created (I foolishly didn’t get them to tell me). Now I’ve cleared the password so they can log on without entering anything into the password box, but as I’m sure this will happen again how do I allow them to create a new password through a form? Otherwise I have to go to them and sort it out via the Tools menu, this is restricted to any other user.
I’ve read the Access Security FAQ and it suggests some code similar to what is shown below, but when this code runs it errors out with a message about not having permissions. So, what do I need to do to temporarily assign the necessary permissions to my users?
Dim strUser As String
Dim strPassword As String
Dim WrkSpce As Workspace
Dim Usr As User
strUser = CurrentUser
Set WrkSpce = DBEngine.Workspaces(0)
Set Usr = WrkSpce.Users(strUser)
If IsNull(Me.PwEntryTxt) Then
MsgBox “no password to change to”
Else
If Me.PwEntryTxt = Me.PwConfirmTxt Then
strPassword = Me.PwEntryTxt
Usr.NewPassword ” “, strPassword
MsgBox strUser & strPassword
Else
MsgBox “Nope, code still aint working”
End If
End If
ExitSub:
Exit Sub
ErrHandler:
MsgBox Err.Description
Resume ExitSub
This is still very much ‘alpha’ code so that’s why it’s offering me the password and user name in a message box, I want some confidence that this is working right The PWEntryTxt and PWConfirmTxt references are text boxes on the form I intend to aloow the users access to to change their passwords. Eventually they’ll be able to change them periodically, but for now it’s just a case of entering a new password once the old one is cleared by myself or the person who will be administrating it.
Thanks
Ian