S
satdist
I have a multi user database that is secure and split. I am looking for
the details of how to add a user password change form. I have tried
numerous times using what I could find in this group as far as
instructions and no luck, there has to be some detail I'm missing. The
following are the last instructions I've tried:
Create a form with the following textboxes:
Current User: set the Control Source =CurrentUser()
OldPW (old password)
NewPW (new password)
ConfirmPW (confirm password)
Add a command button, call it cmdSetPassword and drop in the following
procedure in the Click event
Private Sub cmdSetPassword_Click()
'Change the user's password. Confirm that the passwords typed are the
same.
Dim curr_user As User
On Error Goto FailedPW
If Me.NewPW <> Me.ConfirmPW Then
MsgBox "New passwords are not identical. Please retype
passwords and
try again.", _
vbOKOnly, "Change Password Failed"
Exit Sub
End If
If Len(Me.NewPW) < 4 Or Len(Me.NewPW) > 14 Or IsNull(Me.NewPW) Then
MsgBox "New passwords must be between 4 and 14 characters.",
vbOKOnly, "Change Password Failed"
Exit Sub
End If
Set curr_user = DBEngine.Workspaces(0).Users(CurrentUser())
If IsNull(Me.OldPW) Then
curr_user.NewPassword "", Me.NewPW
Else
curr_user.NewPassword Me.OldPW, Me.NewPW
End If
MsgBox "Your new password has been set and will take effect the
next
time you log on.", _
vbOKOnly, "Password confirmed"
DoCmd.RunCommand acCmdClose
Exit Sub
FailedPW:
If Err.Number = 3033 Then
MsgBox "Old password is incorrect. Please retype and try
again.",
vbOKOnly, "Change Password Failed"
Me.OldPW.SetFocus
Else
MsgBox "Error number " & Err.Number & ": " & Err.Description
End If
End Sub
Thanks for any help you can give.
the details of how to add a user password change form. I have tried
numerous times using what I could find in this group as far as
instructions and no luck, there has to be some detail I'm missing. The
following are the last instructions I've tried:
Create a form with the following textboxes:
Current User: set the Control Source =CurrentUser()
OldPW (old password)
NewPW (new password)
ConfirmPW (confirm password)
Add a command button, call it cmdSetPassword and drop in the following
procedure in the Click event
Private Sub cmdSetPassword_Click()
'Change the user's password. Confirm that the passwords typed are the
same.
Dim curr_user As User
On Error Goto FailedPW
If Me.NewPW <> Me.ConfirmPW Then
MsgBox "New passwords are not identical. Please retype
passwords and
try again.", _
vbOKOnly, "Change Password Failed"
Exit Sub
End If
If Len(Me.NewPW) < 4 Or Len(Me.NewPW) > 14 Or IsNull(Me.NewPW) Then
MsgBox "New passwords must be between 4 and 14 characters.",
vbOKOnly, "Change Password Failed"
Exit Sub
End If
Set curr_user = DBEngine.Workspaces(0).Users(CurrentUser())
If IsNull(Me.OldPW) Then
curr_user.NewPassword "", Me.NewPW
Else
curr_user.NewPassword Me.OldPW, Me.NewPW
End If
MsgBox "Your new password has been set and will take effect the
next
time you log on.", _
vbOKOnly, "Password confirmed"
DoCmd.RunCommand acCmdClose
Exit Sub
FailedPW:
If Err.Number = 3033 Then
MsgBox "Old password is incorrect. Please retype and try
again.",
vbOKOnly, "Change Password Failed"
Me.OldPW.SetFocus
Else
MsgBox "Error number " & Err.Number & ": " & Err.Description
End If
End Sub
Thanks for any help you can give.