Home All Groups Group Topic Archive Search About

Permissions on table object

Author
12 Dec 2008 2:20 AM
RipperT
I created a form for a select few people to create basic (throwaway) user
accounts. The code creates a user, adds it to the default users group, a
custom "LineStaff" group, and optionally a "NotherGroup". If I log on using
any account but my Administrator account, the following error is generated:

You do not have the necessary permissions to use the 'Tables' object. Have
your system administrator or the person who created this object establish
the appropriate permissions for you.

Not sure what the Tables object is. Why is it involved here when the code
doesn't refer to any tables? Many thanks to any who can enlighten me.

Private Sub cmdCreateUser_Click()
On Error GoTo Err_cmdCreateUser_Click

Dim wrkDefault As Workspace
Dim usrNew As User
Dim usrTemp As User
Dim strUserName As String

Set wrkDefault = DBEngine.Workspaces(0)

With wrkDefault

    'Create and append new User.
    strUserName = Me.txtUserName

    Set usrNew = .CreateUser(strUserName)
    usrNew.PID = "1234"
    .Users.Append usrNew

Set usrTemp = .Groups("Users").CreateUser(strUserName)
    .Groups("Users").Users.Append usrTemp
Set usrTemp = .Groups("Users").CreateUser(strUserName)
    .Groups("LineStaff").Users.Append usrTemp

If Me.chkMyCheckbox = True Then
    Set usrTemp = .Groups("Users").CreateUser(strUserName)
    .Groups("NotherGroup").Users.Append usrTemp
End If

MsgBox "User created successfully.  ", vbExclamation, "Success!"
Me.txtUserName = ""
Me.chkControlCenter = False
Set usrTemp = Nothing

End With

Exit_cmdCreateUser_Click:
    Exit Sub

Err_cmdCreateUser_Click:
    MsgBox Err.Description
    Resume Exit_cmdCreateUser_Click

End Sub

Author
12 Dec 2008 5:28 PM
Joan Wild
A user needs to be a member of the Admins Group in order to create user
accounts.  Sounds like they aren't a member.

--
Joan Wild
Microsoft Access MVP
Show quoteHide quote
"RipperT @nOsPaM.nEt>" <<RiPpErT> wrote in message
news:%23u4y1AAXJHA.5084@TK2MSFTNGP03.phx.gbl...
>I created a form for a select few people to create basic (throwaway) user
>accounts. The code creates a user, adds it to the default users group, a
>custom "LineStaff" group, and optionally a "NotherGroup". If I log on using
>any account but my Administrator account, the following error is generated:
>
> You do not have the necessary permissions to use the 'Tables' object. Have
> your system administrator or the person who created this object establish
> the appropriate permissions for you.
>
> Not sure what the Tables object is. Why is it involved here when the code
> doesn't refer to any tables? Many thanks to any who can enlighten me.
>
> Private Sub cmdCreateUser_Click()
> On Error GoTo Err_cmdCreateUser_Click
>
> Dim wrkDefault As Workspace
> Dim usrNew As User
> Dim usrTemp As User
> Dim strUserName As String
>
> Set wrkDefault = DBEngine.Workspaces(0)
>
> With wrkDefault
>
>    'Create and append new User.
>    strUserName = Me.txtUserName
>
>    Set usrNew = .CreateUser(strUserName)
>    usrNew.PID = "1234"
>    .Users.Append usrNew
>
> Set usrTemp = .Groups("Users").CreateUser(strUserName)
>    .Groups("Users").Users.Append usrTemp
> Set usrTemp = .Groups("Users").CreateUser(strUserName)
>    .Groups("LineStaff").Users.Append usrTemp
>
> If Me.chkMyCheckbox = True Then
>    Set usrTemp = .Groups("Users").CreateUser(strUserName)
>    .Groups("NotherGroup").Users.Append usrTemp
> End If
>
> MsgBox "User created successfully.  ", vbExclamation, "Success!"
> Me.txtUserName = ""
> Me.chkControlCenter = False
> Set usrTemp = Nothing
>
> End With
>
> Exit_cmdCreateUser_Click:
>    Exit Sub
>
> Err_cmdCreateUser_Click:
>    MsgBox Err.Description
>    Resume Exit_cmdCreateUser_Click
>
> End Sub
>