Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using String to Set User Password 3

Status
Not open for further replies.

Zycmi

IS-IT--Management
Jun 19, 2002
42
CA

I am trying to create a small form with a command button that lets you change your password.

I am looking for a string that could do this.
i don't know the proper syntax for this, however, Here is what I am looking to do.

InputBox1: Collects the old password
InputBox2: Enter New Password
InputBox3: Verify New Password

The user who's password will change will always be CurrentUser()
What is the string I would need to take these variables into the process of changing the password. If anyone could help me, please let me know.
Thanks in advance for your help!

Zycmi
 
I have a samole db all ready with some thing pre built to do this, email me if you would like it...

(I can only send mail to a US email...)

--James junior1544@jmjpc.net
Life is change. To deny change is to deny life.
 
You may paste the following function into your standard module.

Read (and verify) the users inputs thru some form. When clicking OK button, then call this function.

Hope it helps.

Hayo

Code:
Function ChangePassword(ByVal strOldPW As String, ByVal strNewPW As String) As Boolean
'Accepts: The user's old and new passwords
'Purpose: Changes the user's password in the system database
'Returns: True if successful, else False with Err set to error code

    Dim wsWorkspace As Workspace
    
    Set wsWorkspace = DBEngine.Workspaces(0)
    On Error Resume Next
    wsWorkspace.Users(CurrentUser()).NewPassword strOldPW, strNewPW
    Select Case Err
        Case 0
            ChangePassword = True
        Case 3033
            MsgBox "Please enter valid password.", vbExclamation, "Wrong password"
            ChangePassword = False
        Case Else
            MsgBox "Password NOT changed! " & str(Err) & " " & Error$, _
                    vbCritical, _
                    "Error when modifying password"
            ChangePassword = False
    End Select
End Function
 
hayo,
I tried your code,
but sorry it doesn't work under Access 2000
cause of the dim wsWorkspace as Workspace.

The rest i think is ok.

-FirstDirk
 
try this FirstDirk,

Dim wsp As Workspace
If Nz(txtNewPassword) <> Nz(txtVerifyPassword) Then
txtVerifyPassword.SetFocus
Beep
MsgBox &quot;Verify the new password by retyping it in the Verify box and clicking OK.&quot;, vbInformation
Exit Sub
End If
Set wsp = DBEngine.Workspaces(0)
On Error GoTo ErrorHandler
wsp.Users(CurrentUser).NewPassword Nz(txtOldPassword), Nz(txtNewPassword)
DoCmd.Close
ErrorExit:
Set wsp = Nothing
Exit Sub
ErrorHandler:
If Err = 3033 Then
txtOldPassword.SetFocus
Beep
MsgBox &quot;The password you entered in the Old Password box is incorrect.&quot; _
& vbCrLf & vbCrLf _
& &quot;Please enter the correct password for this account.&quot;, _
vbInformation
Resume ErrorExit
End If
Err.Raise Err.Number
junior1544@jmjpc.net
Life is change. To deny change is to deny life.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top