G
Guest
I have got to be the worst programmer ever. Truthfully I'm not a programmer
at all, but I have to do this anyway and I need help.
The following code is supposed to create a new user and add that user to the
"Users" group:
Private Function AddUser(ByVal strUser As String, _
ByVal strPID As String, _
Optional ByVal strPwd As String) As Boolean
Dim catDB As ADOX.Catalog
On Error GoTo AddUser_Err
' Instantiate the Catalog object.
Set catDB = New ADOX.Catalog
With catDB
' Open Catalog object by using connection to the current
' database.
.ActiveConnection = CurrentProject.Connection
' Create new user account.
.Users.Append strUser, strPwd, strPID
' Append new user account to default Users group.
.Groups("Users").Users.Append strUser
End With
' Close Catalog object.
Set catDB = Nothing
AddUser = True
AddUser_Err:
Msgbox Err.Number & ":" & Err.Description
AddUser = False
End Function
*************End Code**************
I'm not sure how to use this code. From what I understand, I need to create
a form that has three unbound textboxes. One named strUser, another named
strPID and the last named strPwd. I then need to create a button which calls
the addUser function when clicked. The problem is, when I click the build
button for the onclick event of my button, it creats a 'Private Sub'. This
code is a 'Private Function', how do I get the button to run the function?
Additionally, during my attempts to do this, I've added the code in the
coding window and then tried to compile the db but I get an error message on
the line that says: .Users.Append strUser, strPwd, strPID
The error message says: Compile Error: Wrong number of arguments or invalid
property assignment.
I don't know what that means and that's pretty much the most important part
of the code. Take note that I have already added the Microsoft ADO Ext. 2.5
for DDL and Security Reference to the References window. Also, I am trying to
run this code while logged in as an admin in my secured.mdw workgroup file.
at all, but I have to do this anyway and I need help.
The following code is supposed to create a new user and add that user to the
"Users" group:
Private Function AddUser(ByVal strUser As String, _
ByVal strPID As String, _
Optional ByVal strPwd As String) As Boolean
Dim catDB As ADOX.Catalog
On Error GoTo AddUser_Err
' Instantiate the Catalog object.
Set catDB = New ADOX.Catalog
With catDB
' Open Catalog object by using connection to the current
' database.
.ActiveConnection = CurrentProject.Connection
' Create new user account.
.Users.Append strUser, strPwd, strPID
' Append new user account to default Users group.
.Groups("Users").Users.Append strUser
End With
' Close Catalog object.
Set catDB = Nothing
AddUser = True
AddUser_Err:
Msgbox Err.Number & ":" & Err.Description
AddUser = False
End Function
*************End Code**************
I'm not sure how to use this code. From what I understand, I need to create
a form that has three unbound textboxes. One named strUser, another named
strPID and the last named strPwd. I then need to create a button which calls
the addUser function when clicked. The problem is, when I click the build
button for the onclick event of my button, it creats a 'Private Sub'. This
code is a 'Private Function', how do I get the button to run the function?
Additionally, during my attempts to do this, I've added the code in the
coding window and then tried to compile the db but I get an error message on
the line that says: .Users.Append strUser, strPwd, strPID
The error message says: Compile Error: Wrong number of arguments or invalid
property assignment.
I don't know what that means and that's pretty much the most important part
of the code. Take note that I have already added the Microsoft ADO Ext. 2.5
for DDL and Security Reference to the References window. Also, I am trying to
run this code while logged in as an admin in my secured.mdw workgroup file.