I have a form that pops up for new database users so they can setup a new password. (I setup the user's name in the built-in security tools in Access.) In that form I have code to set the password from "" to the new one they set on the form.
See the code that sets the password...
When I run the code and get to the Set usr = cat.Users.Item(strCurrUser) statement it gives me an error...
"Run-Time error '3251': Object or provider is not capable of performing requested operation."
I've looked around difference websites and I'm not sure what this is. Any ideas?
Database Specifics:
Access 2003 Split Database
Refererences to...
- Microsoft ADO Ext. 2.8 for DDL and Security
- Microsoft ActiveX Data Objects 2.7 Library
Thanks!
See the code that sets the password...
Code:
Private Sub cmdSetPassword_Click()
'Adds a new password for the currentuser based on the criteria
'-----------------------------------------------------------------
On Error GoTo Error_Handler
'Declare DIMs
Dim cat As ADOX.Catalog
Dim cn As New ADODB.Connection
Dim usr As ADOX.User
Dim strCurrUser As String
'Set usrNew = New ADOX.User
Set cn = CurrentProject.Connection 'Sets activeconnection to current project
Set cat = New ADOX.Catalog
cat.ActiveConnection = cn
strCurrUser = CurrentProject.Connection.Properties("user id") 'Gets Current User Name
Set usr = cat.Users.Item(strCurrUser)
If Me.txtNewPassword = Me.txtRepeatPassword Then 'Checks to make sure the new password is equal to the repeat password
usr.ChangePassword "", Me.txtNewPassword 'Changes password from "" to new password on form
MsgBox "Password has been set!", vbOKOnly, "Network Services Access Database" 'Msgbox
DoCmd.RunMacro "macro_Times_Logged_In" 'Runs the macro to add to the Time logged in field
DoCmd.Close acForm, conFormName 'Closes Form
Else 'New password is not equal to the repeat password
strMsgBoxMsg = "Passwords do not match, please re-enter the password!" 'Define message
strMsgBoxStyle = vbOKCancel Or vbDefaultButton1 'Define buttons
strMsgBoxTitle = "Network Services Access Database" 'Define title
strMsgBoxResponse = MsgBox(strMsgBoxMsg, strMsgBoxStyle, strMsgBoxTitle) 'Display message
If strMsgBoxResponse = vbOK Then 'User chose Ok
Me.txtNewPassword = ""
Me.txtRepeatPassword = ""
Me.txtNewPassword.SetFocus 'Sets focus to this field
Me.txtRepeatPassword.Enabled = False
Me.cmdSetPassword.Enabled = False
Else
MsgBox "Access to this database can not be accessed without setting a password!", vbOKOnly, "Network Services Access Database"
Me.Undo
DoCmd.Quit
End If
End If
'Clean up
Set cat.ActiveConnection = Nothing
Set cat = Nothing
Set usr = Nothing
Exit_Procedure:
'Error Cleanup
On Error Resume Next
DoCmd.Hourglass False
DoCmd.SetWarnings True
varReturnVal = SysCmd(acSysCmdClearStatus)
Exit Sub
Error_Handler:
MsgBox "An error has occured in this application. " _
& "Please contact the database administrator and " _
& "tell them this information: " _
& vbCrLf & vbCrLf & "Error Number " & Err.Number & ", " _
& Err.Description, _
Buttons:=vbCritical, Title:="Network Services Access Database"
Resume Exit_Procedure
Resume
'-----------------------------------------------------------------
'End of Code
End Sub
When I run the code and get to the Set usr = cat.Users.Item(strCurrUser) statement it gives me an error...
"Run-Time error '3251': Object or provider is not capable of performing requested operation."
I've looked around difference websites and I'm not sure what this is. Any ideas?
Database Specifics:
Access 2003 Split Database
Refererences to...
- Microsoft ADO Ext. 2.8 for DDL and Security
- Microsoft ActiveX Data Objects 2.7 Library
Thanks!
Last edited: