Hi Sam
Make a form with three textboxes and two command buttons. Name the
textboxes txtOldPwd, txtNewPwd and txtVerify. Set the InputMask property
for eack to Password.
Name the command buttons cmdCancel and cmdOK. Give them appropriate
captions. Paste the following code into your form's module. Note the
Option Compare Binary is important because passwords are case sensitive.
Option Explicit
Option Compare Binary
Private Sub cmdCancel_Click()
DoCmd.Close acForm, Me.Name
End Sub
Private Sub cmdOK_Click()
Dim sOldPwd As String, sNewPwd As String, sVerify As String
On Error GoTo ProcErr
sOldPwd = txtOldPwd & ""
sNewPwd = txtNewPwd & ""
sVerify = txtVerify & ""
If sNewPwd = sVerify Then
DBEngine.Workspaces(0).Users(CurrentUser()).NewPassword _
sOldPwd, sNewPwd
DoCmd.Close acForm, Me.Name
ElseIf sVerify = "" Then
Err.Raise vbObjectError + 1
Else
Err.Raise vbObjectError + 2
End If
ProcEnd:
Exit Sub
ProcErr:
Dim msg As String
Select Case Err
Case vbObjectError + 1
txtVerify.SetFocus
msg = "No Verify Password|" & _
"Type the new password again in the Verify box before clicking
OK"
Case vbObjectError + 2
txtNewPwd = Null
txtVerify = Null
txtNewPwd.SetFocus
msg = "Verify Failed|" & _
"The New Password does not match what you typed in the Verify
box.|"
& _
"Please re-enter them both"
Case 3001
txtNewPwd = Null
txtVerify = Null
txtNewPwd.SetFocus
If Len(sNewPwd) > 14 Then
msg = "Password too long|" & _
"The maximum length for a password is 14 characters"
Else
msg = "Invalid Password|" & _
"The password you entered contains invalid characters"
End If
Case 3033
txtOldPwd = Null
txtNewPwd = Null
txtVerify = Null
txtOldPwd.SetFocus
msg = "Incorrect Password|" & _
"The old password you entered was incorrect|" & _
Please enter the correct password"
Case Else
txtOldPwd = Null
txtNewPwd = Null
txtVerify = Null
txtOldPwd.SetFocus
msg = Err.Description
End Select
MsgBox Replace(msg, "|", vbCrLf), vbExclamation, "Error Changing
Password"
Resume ProcEnd
End Sub
--
Good Luck!
Graham Mandeno [Access MVP]
Auckland, New Zealand
Sam said:
Hello Graham
How would a newbie set this up???
:
Hi Brad
All you require is one line of code:
DBEngine.Workspaces(0).Users(CurrentUser()).NewPassword strOldPwd,
strNewPwd
Of course, you will need to wrap this up in a form which asks for the
old
password and the new one (twice, to verify) and checks the two new
ones
are
identical.
BTW, if you specify "Password" as the InputMask on a textbox then the
characters typed will be displayed as ****.
--
Good Luck!
Graham Mandeno [Access MVP]
Auckland, New Zealand
What are the calls to implement into an Access 2000 app that would
allow
me as the programmer to give the user a form where they can
set/change
their password instead of using the "Access Security and GRoups"
area?
I
have removed all of the Access built in menus etc... and therefore
need
to
give the user the ability to do this themselves... I only want them
to
set/change their own password. I dpo not want them scrolling through
the
list of users and groups etc...
Thanks,
Brad