Creating Administrative Workspace for Password Reseting - Compile

J

Janet

I followed Microsoft's directions for setting up a database form where users
can change their passwords and administrators can reset lost passwords. The
user form works great. I can't get the Administrative part to work. I keep
getting a compile error when I click the "reset" or "change password"
buttons, and the VB Editor opens the code with "DIM ws As WorkSpace"
selected, and the words above the asterisks (below) are highlighted in bright
yellow. (See code below). What is wrong? Why do I get a compile error?
Thanks so much, Janet


Public Sub ChangeResetPassword(StrAction As String, StrUsername As _
String, StrAdminLogon As String, StrAdminPass As String, Optional _
StrNewPassword As Variant)

'*******************************************************************************
' This function is for allowing the administrator to change anyone's passwor
'*******************************************************************************

Dim ws As Workspace
On Error GoTo ChangeResetPassword:

' Create a new Administrative Workspace. If The StrAction passed to the
' function is "Change" then change the Password of the User named in
' StrUsername to the password saved in StrNewPassword.
' If the StrAction passed is "Reset", Then reset the password of
' the User mentioned in StrUsername. If neither "Change" or "Reset"
' is passed to the function in the StrAction argument, inform the
' user of an error and exit the procedure.

Set ws = DBEngine.CreateWorkspace(0"AdminWorkspace", StrAdminLogon, _
StrAdminPass)
If StrAction = "change" Then

If Not IsNull(StrNewPassword) Then
ws.Users(StrUsername).NewPassword "", StrNewPassword
MsgBox "Password Change Successful", vbOKOnly
Else
MsgBox "When Attempting to Change A User's Password, You " & _
"Must Include a New Password", vbOKOnly
End If

Else

If StrAction = "reset" Then
'When the current user is in the admins group and reseting
'his/her own password, the current password must be supplied.
'In all other cases, the current user password is not needed
'for a reset.
If StrUsername = ws.UserName And StrAdminLogon = ws.UserName Then
ws.Users(StrUsername).NewPassword StrAdminPass, ""
MsgBox "Password Successfully Reset", vbOKOnly
Else
ws.Users(StrUsername).NewPassword "", ""
MsgBox "Password Successfully Reset", vbOKOnly
End If
Else
MsgBox "You must Select a StrAction of either '" & "Change'" & _
"' or '" & "Reset'.", vbOKOnly
End If

ws.Close
Set ws = Nothing
Exit Sub

ChangeResetPassword:
MsgBox Err.Description
End Sub



Public Sub ChangeUserPassword(StrUsername As String, StrOldPassword _
As String, StrNewPassword As String)

'*******************************************************************************
' This function is for allowing a user to change his/her own password ONL
'*******************************************************************************

On Error GoTo ChangeUserPassword_Err:
DBEngine(0).Users(StrUsername).NewPassword StrOldPassword, _
StrNewPassword

MsgBox "Password Change Successful", vbInformation
Exit Sub

ChangeUserPassword_Err:
MsgBox Err.Description
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top