Home All Groups Group Topic Archive Search About

Show/Hide objects based on Security Groups

Author
13 Nov 2006 4:29 PM
bigpalooka
With my split, multi-user, secured Access 2000 db, I have 3 user groups -
Admins, Read-Only, and Full-User (built-in groups).  I'd like to disable or
hide some command buttons I have on my switchboard - "User Maintenance", and
"Change Password" for all but Admins.  I have code that finds out which group
the logged-in user belongs to, but it doesn't allow the non-Admin users to
run it:
strUserLevel = Workspaces(0).Users(Workspaces(0).UserName).Groups(0).Name
so I can't hide or show objects based on the user level.
- Is this by design, or is there a way to do this?

Author
13 Nov 2006 6:37 PM
Joan Wild
You may find it easier if you create your own unbound form for your
switchboard.  It is more flexible than the built-in switchboard manager,
especially for something like this.

There is code in the security FAQ you can use to determine if a user is
member of a group.

Then in the open event of your menu form you'd use...

If faq_IsUserInGroup("ReadOnly",CurrentUser) then
    Me.cmdWhatever.Visible = False
    Me.cmdSomething.Visible = True
etc.
Else
    Me.cmdWhatever.Visible = True
    Me.cmdSomething.Visible = True
etc.
End If

The FAQ can downloaded from
http://support.microsoft.com/?id=207793


--
Joan Wild
Microsoft Access MVP

bigpalooka wrote:
Show quoteHide quote
> With my split, multi-user, secured Access 2000 db, I have 3 user
> groups - Admins, Read-Only, and Full-User (built-in groups).  I'd
> like to disable or hide some command buttons I have on my switchboard
> - "User Maintenance", and "Change Password" for all but Admins.  I
> have code that finds out which group the logged-in user belongs to,
> but it doesn't allow the non-Admin users to run it:
> strUserLevel =
> Workspaces(0).Users(Workspaces(0).UserName).Groups(0).Name
> so I can't hide or show objects based on the user level.
> - Is this by design, or is there a way to do this?
Author
13 Nov 2006 7:08 PM
bigpalooka
I'm still getting error 3112: Record cannot be read.  No Read permission on
MSysGroupList.  I tried both 'faq_ListGroupsofUser' and 'faq_IsUserInGroup'. 
It works fine with Admins, but not with the other groups.

jp

Show quoteHide quote
"Joan Wild" wrote:

> You may find it easier if you create your own unbound form for your
> switchboard.  It is more flexible than the built-in switchboard manager,
> especially for something like this.
>
> There is code in the security FAQ you can use to determine if a user is
> member of a group.
>
> Then in the open event of your menu form you'd use...
>
> If faq_IsUserInGroup("ReadOnly",CurrentUser) then
>     Me.cmdWhatever.Visible = False
>     Me.cmdSomething.Visible = True
> etc.
> Else
>     Me.cmdWhatever.Visible = True
>     Me.cmdSomething.Visible = True
> etc.
> End If
>
> The FAQ can downloaded from
http://support.microsoft.com/?id=207793
>
>
> --
> Joan Wild
> Microsoft Access MVP
>
> bigpalooka wrote:
> > With my split, multi-user, secured Access 2000 db, I have 3 user
> > groups - Admins, Read-Only, and Full-User (built-in groups).  I'd
> > like to disable or hide some command buttons I have on my switchboard
> > - "User Maintenance", and "Change Password" for all but Admins.  I
> > have code that finds out which group the logged-in user belongs to,
> > but it doesn't allow the non-Admin users to run it:
> > strUserLevel =
> > Workspaces(0).Users(Workspaces(0).UserName).Groups(0).Name
> > so I can't hide or show objects based on the user level.
> > - Is this by design, or is there a way to do this?
>
>
>
Author
13 Nov 2006 7:40 PM
Joan Wild
Can you post the code you are using?  I haven't heard of MSysGroupList.

--
Joan Wild
Microsoft Access MVP

bigpalooka wrote:
Show quoteHide quote
> I'm still getting error 3112: Record cannot be read.  No Read
> permission on MSysGroupList.  I tried both 'faq_ListGroupsofUser' and
> 'faq_IsUserInGroup'. It works fine with Admins, but not with the
> other groups.
>
> jp
>
> "Joan Wild" wrote:
>
>> You may find it easier if you create your own unbound form for your
>> switchboard.  It is more flexible than the built-in switchboard
>> manager, especially for something like this.
>>
>> There is code in the security FAQ you can use to determine if a user
>> is member of a group.
>>
>> Then in the open event of your menu form you'd use...
>>
>> If faq_IsUserInGroup("ReadOnly",CurrentUser) then
>>     Me.cmdWhatever.Visible = False
>>     Me.cmdSomething.Visible = True
>> etc.
>> Else
>>     Me.cmdWhatever.Visible = True
>>     Me.cmdSomething.Visible = True
>> etc.
>> End If
>>
>> The FAQ can downloaded from
>>  http://support.microsoft.com/?id=207793
>>
>>
>> --
>> Joan Wild
>> Microsoft Access MVP
>>
>> bigpalooka wrote:
>>> With my split, multi-user, secured Access 2000 db, I have 3 user
>>> groups - Admins, Read-Only, and Full-User (built-in groups).  I'd
>>> like to disable or hide some command buttons I have on my
>>> switchboard - "User Maintenance", and "Change Password" for all but
>>> Admins.  I have code that finds out which group the logged-in user
>>> belongs to, but it doesn't allow the non-Admin users to run it:
>>> strUserLevel =
>>> Workspaces(0).Users(Workspaces(0).UserName).Groups(0).Name
>>> so I can't hide or show objects based on the user level.
>>> - Is this by design, or is there a way to do this?
Author
13 Nov 2006 8:21 PM
bigpalooka
Here's my code - it's pretty straightforward:

Private Sub cmdOK_Click()
    On Error GoTo errhnd

    Dim wsp As DAO.Workspace
    Dim usr As DAO.User
    Dim strUserName As String

    strUserName = Application.CurrentUser

    If Me.txtNewPassword = Me.txtConfirmPassword Then
       Set wsp = DAO.Workspaces(0)
       Set usr = wsp.Users(strUserName)
       usr.NewPassword Me.txtOldPassword, Me.txtNewPassword
                Else
                    MsgBox "Re-enter your Passwords.  Your NewPassword
doesn't match your ConfirmPassword", vbInformation + vbOKOnly, "Passwords
don't Match"
- etc etc - assorted code to check for pwd length, etc is removed.

you're right - I can't find MSysGroupList or MSysUserList in the system
tables.  The closest I come is MSysGroups in the mdw file.
??
jp

Show quoteHide quote
"Joan Wild" wrote:

> Can you post the code you are using?  I haven't heard of MSysGroupList.
>
> --
> Joan Wild
> Microsoft Access MVP
>
> bigpalooka wrote:
> > I'm still getting error 3112: Record cannot be read.  No Read
> > permission on MSysGroupList.  I tried both 'faq_ListGroupsofUser' and
> > 'faq_IsUserInGroup'. It works fine with Admins, but not with the
> > other groups.
> >
> > jp
> >
> > "Joan Wild" wrote:
> >
> >> You may find it easier if you create your own unbound form for your
> >> switchboard.  It is more flexible than the built-in switchboard
> >> manager, especially for something like this.
> >>
> >> There is code in the security FAQ you can use to determine if a user
> >> is member of a group.
> >>
> >> Then in the open event of your menu form you'd use...
> >>
> >> If faq_IsUserInGroup("ReadOnly",CurrentUser) then
> >>     Me.cmdWhatever.Visible = False
> >>     Me.cmdSomething.Visible = True
> >> etc.
> >> Else
> >>     Me.cmdWhatever.Visible = True
> >>     Me.cmdSomething.Visible = True
> >> etc.
> >> End If
> >>
> >> The FAQ can downloaded from
> >>  http://support.microsoft.com/?id=207793
> >>
> >>
> >> --
> >> Joan Wild
> >> Microsoft Access MVP
> >>
> >> bigpalooka wrote:
> >>> With my split, multi-user, secured Access 2000 db, I have 3 user
> >>> groups - Admins, Read-Only, and Full-User (built-in groups).  I'd
> >>> like to disable or hide some command buttons I have on my
> >>> switchboard - "User Maintenance", and "Change Password" for all but
> >>> Admins.  I have code that finds out which group the logged-in user
> >>> belongs to, but it doesn't allow the non-Admin users to run it:
> >>> strUserLevel =
> >>> Workspaces(0).Users(Workspaces(0).UserName).Groups(0).Name
> >>> so I can't hide or show objects based on the user level.
> >>> - Is this by design, or is there a way to do this?
>
>
>
Author
14 Nov 2006 3:04 PM
Joan Wild
I don't see anything wrong with the code; it works here for a limited user.

--
Joan Wild
Microsoft Access MVP

bigpalooka wrote:
Show quoteHide quote
> Here's my code - it's pretty straightforward:
>
> Private Sub cmdOK_Click()
>    On Error GoTo errhnd
>
>    Dim wsp As DAO.Workspace
>    Dim usr As DAO.User
>    Dim strUserName As String
>
>    strUserName = Application.CurrentUser
>
>    If Me.txtNewPassword = Me.txtConfirmPassword Then
>       Set wsp = DAO.Workspaces(0)
>       Set usr = wsp.Users(strUserName)
>       usr.NewPassword Me.txtOldPassword, Me.txtNewPassword
>                Else
>                    MsgBox "Re-enter your Passwords.  Your NewPassword
> doesn't match your ConfirmPassword", vbInformation + vbOKOnly,
> "Passwords don't Match"
> - etc etc - assorted code to check for pwd length, etc is removed.
>
> you're right - I can't find MSysGroupList or MSysUserList in the
> system tables.  The closest I come is MSysGroups in the mdw file.
> ??
> jp
>
> "Joan Wild" wrote:
>
>> Can you post the code you are using?  I haven't heard of
>> MSysGroupList.
>>
>> --
>> Joan Wild
>> Microsoft Access MVP
>>
>> bigpalooka wrote:
>>> I'm still getting error 3112: Record cannot be read.  No Read
>>> permission on MSysGroupList.  I tried both 'faq_ListGroupsofUser'
>>> and 'faq_IsUserInGroup'. It works fine with Admins, but not with the
>>> other groups.
>>>
>>> jp
>>>
>>> "Joan Wild" wrote:
>>>
>>>> You may find it easier if you create your own unbound form for your
>>>> switchboard.  It is more flexible than the built-in switchboard
>>>> manager, especially for something like this.
>>>>
>>>> There is code in the security FAQ you can use to determine if a
>>>> user is member of a group.
>>>>
>>>> Then in the open event of your menu form you'd use...
>>>>
>>>> If faq_IsUserInGroup("ReadOnly",CurrentUser) then
>>>>     Me.cmdWhatever.Visible = False
>>>>     Me.cmdSomething.Visible = True
>>>> etc.
>>>> Else
>>>>     Me.cmdWhatever.Visible = True
>>>>     Me.cmdSomething.Visible = True
>>>> etc.
>>>> End If
>>>>
>>>> The FAQ can downloaded from
>>>>  http://support.microsoft.com/?id=207793
>>>>
>>>>
>>>> --
>>>> Joan Wild
>>>> Microsoft Access MVP
>>>>
>>>> bigpalooka wrote:
>>>>> With my split, multi-user, secured Access 2000 db, I have 3 user
>>>>> groups - Admins, Read-Only, and Full-User (built-in groups).  I'd
>>>>> like to disable or hide some command buttons I have on my
>>>>> switchboard - "User Maintenance", and "Change Password" for all
>>>>> but Admins.  I have code that finds out which group the logged-in
>>>>> user belongs to, but it doesn't allow the non-Admin users to run
>>>>> it: strUserLevel =
>>>>> Workspaces(0).Users(Workspaces(0).UserName).Groups(0).Name
>>>>> so I can't hide or show objects based on the user level.
>>>>> - Is this by design, or is there a way to do this?
Author
14 Nov 2006 5:01 PM
bigpalooka
OK - I'll investigate.  There may be something hidden somewhere in the db
that's keeping me up at night.

jp

Show quoteHide quote
"Joan Wild" wrote:

> I don't see anything wrong with the code; it works here for a limited user.
>
> --
> Joan Wild
> Microsoft Access MVP
>
> bigpalooka wrote:
> > Here's my code - it's pretty straightforward:
> >
> > Private Sub cmdOK_Click()
> >    On Error GoTo errhnd
> >
> >    Dim wsp As DAO.Workspace
> >    Dim usr As DAO.User
> >    Dim strUserName As String
> >
> >    strUserName = Application.CurrentUser
> >
> >    If Me.txtNewPassword = Me.txtConfirmPassword Then
> >       Set wsp = DAO.Workspaces(0)
> >       Set usr = wsp.Users(strUserName)
> >       usr.NewPassword Me.txtOldPassword, Me.txtNewPassword
> >                Else
> >                    MsgBox "Re-enter your Passwords.  Your NewPassword
> > doesn't match your ConfirmPassword", vbInformation + vbOKOnly,
> > "Passwords don't Match"
> > - etc etc - assorted code to check for pwd length, etc is removed.
> >
> > you're right - I can't find MSysGroupList or MSysUserList in the
> > system tables.  The closest I come is MSysGroups in the mdw file.
> > ??
> > jp
> >
> > "Joan Wild" wrote:
> >
> >> Can you post the code you are using?  I haven't heard of
> >> MSysGroupList.
> >>
> >> --
> >> Joan Wild
> >> Microsoft Access MVP
> >>
> >> bigpalooka wrote:
> >>> I'm still getting error 3112: Record cannot be read.  No Read
> >>> permission on MSysGroupList.  I tried both 'faq_ListGroupsofUser'
> >>> and 'faq_IsUserInGroup'. It works fine with Admins, but not with the
> >>> other groups.
> >>>
> >>> jp
> >>>
> >>> "Joan Wild" wrote:
> >>>
> >>>> You may find it easier if you create your own unbound form for your
> >>>> switchboard.  It is more flexible than the built-in switchboard
> >>>> manager, especially for something like this.
> >>>>
> >>>> There is code in the security FAQ you can use to determine if a
> >>>> user is member of a group.
> >>>>
> >>>> Then in the open event of your menu form you'd use...
> >>>>
> >>>> If faq_IsUserInGroup("ReadOnly",CurrentUser) then
> >>>>     Me.cmdWhatever.Visible = False
> >>>>     Me.cmdSomething.Visible = True
> >>>> etc.
> >>>> Else
> >>>>     Me.cmdWhatever.Visible = True
> >>>>     Me.cmdSomething.Visible = True
> >>>> etc.
> >>>> End If
> >>>>
> >>>> The FAQ can downloaded from
> >>>>  http://support.microsoft.com/?id=207793
> >>>>
> >>>>
> >>>> --
> >>>> Joan Wild
> >>>> Microsoft Access MVP
> >>>>
> >>>> bigpalooka wrote:
> >>>>> With my split, multi-user, secured Access 2000 db, I have 3 user
> >>>>> groups - Admins, Read-Only, and Full-User (built-in groups).  I'd
> >>>>> like to disable or hide some command buttons I have on my
> >>>>> switchboard - "User Maintenance", and "Change Password" for all
> >>>>> but Admins.  I have code that finds out which group the logged-in
> >>>>> user belongs to, but it doesn't allow the non-Admin users to run
> >>>>> it: strUserLevel =
> >>>>> Workspaces(0).Users(Workspaces(0).UserName).Groups(0).Name
> >>>>> so I can't hide or show objects based on the user level.
> >>>>> - Is this by design, or is there a way to do this?
>
>
>
Author
14 Nov 2006 9:31 PM
bigpalooka
MSysGroupList and MSysUserList are Queries in the mdw file.



Show quoteHide quote
"Joan Wild" wrote:

> Can you post the code you are using?  I haven't heard of MSysGroupList.
>
> --
> Joan Wild
> Microsoft Access MVP
>
> bigpalooka wrote:
> > I'm still getting error 3112: Record cannot be read.  No Read
> > permission on MSysGroupList.  I tried both 'faq_ListGroupsofUser' and
> > 'faq_IsUserInGroup'. It works fine with Admins, but not with the
> > other groups.
> >
> > jp
> >
> > "Joan Wild" wrote:
> >
> >> You may find it easier if you create your own unbound form for your
> >> switchboard.  It is more flexible than the built-in switchboard
> >> manager, especially for something like this.
> >>
> >> There is code in the security FAQ you can use to determine if a user
> >> is member of a group.
> >>
> >> Then in the open event of your menu form you'd use...
> >>
> >> If faq_IsUserInGroup("ReadOnly",CurrentUser) then
> >>     Me.cmdWhatever.Visible = False
> >>     Me.cmdSomething.Visible = True
> >> etc.
> >> Else
> >>     Me.cmdWhatever.Visible = True
> >>     Me.cmdSomething.Visible = True
> >> etc.
> >> End If
> >>
> >> The FAQ can downloaded from
> >>  http://support.microsoft.com/?id=207793
> >>
> >>
> >> --
> >> Joan Wild
> >> Microsoft Access MVP
> >>
> >> bigpalooka wrote:
> >>> With my split, multi-user, secured Access 2000 db, I have 3 user
> >>> groups - Admins, Read-Only, and Full-User (built-in groups).  I'd
> >>> like to disable or hide some command buttons I have on my
> >>> switchboard - "User Maintenance", and "Change Password" for all but
> >>> Admins.  I have code that finds out which group the logged-in user
> >>> belongs to, but it doesn't allow the non-Admin users to run it:
> >>> strUserLevel =
> >>> Workspaces(0).Users(Workspaces(0).UserName).Groups(0).Name
> >>> so I can't hide or show objects based on the user level.
> >>> - Is this by design, or is there a way to do this?
>
>
>
Author
14 Nov 2006 10:28 PM
Joan Wild
Have you opened the mdw (before now) directly and been mucking around?

--
Joan Wild
Microsoft Access MVP

bigpalooka wrote:
Show quoteHide quote
> MSysGroupList and MSysUserList are Queries in the mdw file.
>
>
>
> "Joan Wild" wrote:
>
>> Can you post the code you are using?  I haven't heard of
>> MSysGroupList.
>>
>> --
>> Joan Wild
>> Microsoft Access MVP
>>
>> bigpalooka wrote:
>>> I'm still getting error 3112: Record cannot be read.  No Read
>>> permission on MSysGroupList.  I tried both 'faq_ListGroupsofUser'
>>> and 'faq_IsUserInGroup'. It works fine with Admins, but not with the
>>> other groups.
>>>
>>> jp
>>>
>>> "Joan Wild" wrote:
>>>
>>>> You may find it easier if you create your own unbound form for your
>>>> switchboard.  It is more flexible than the built-in switchboard
>>>> manager, especially for something like this.
>>>>
>>>> There is code in the security FAQ you can use to determine if a
>>>> user is member of a group.
>>>>
>>>> Then in the open event of your menu form you'd use...
>>>>
>>>> If faq_IsUserInGroup("ReadOnly",CurrentUser) then
>>>>     Me.cmdWhatever.Visible = False
>>>>     Me.cmdSomething.Visible = True
>>>> etc.
>>>> Else
>>>>     Me.cmdWhatever.Visible = True
>>>>     Me.cmdSomething.Visible = True
>>>> etc.
>>>> End If
>>>>
>>>> The FAQ can downloaded from
>>>>  http://support.microsoft.com/?id=207793
>>>>
>>>>
>>>> --
>>>> Joan Wild
>>>> Microsoft Access MVP
>>>>
>>>> bigpalooka wrote:
>>>>> With my split, multi-user, secured Access 2000 db, I have 3 user
>>>>> groups - Admins, Read-Only, and Full-User (built-in groups).  I'd
>>>>> like to disable or hide some command buttons I have on my
>>>>> switchboard - "User Maintenance", and "Change Password" for all
>>>>> but Admins.  I have code that finds out which group the logged-in
>>>>> user belongs to, but it doesn't allow the non-Admin users to run
>>>>> it: strUserLevel =
>>>>> Workspaces(0).Users(Workspaces(0).UserName).Groups(0).Name
>>>>> so I can't hide or show objects based on the user level.
>>>>> - Is this by design, or is there a way to do this?
Author
15 Nov 2006 2:49 PM
bigpalooka
nope

Show quoteHide quote
"Joan Wild" wrote:

> Have you opened the mdw (before now) directly and been mucking around?
>
> --
> Joan Wild
> Microsoft Access MVP
>
> bigpalooka wrote:
> > MSysGroupList and MSysUserList are Queries in the mdw file.
> >
> >
> >
> > "Joan Wild" wrote:
> >
> >> Can you post the code you are using?  I haven't heard of
> >> MSysGroupList.
> >>
> >> --
> >> Joan Wild
> >> Microsoft Access MVP
> >>
> >> bigpalooka wrote:
> >>> I'm still getting error 3112: Record cannot be read.  No Read
> >>> permission on MSysGroupList.  I tried both 'faq_ListGroupsofUser'
> >>> and 'faq_IsUserInGroup'. It works fine with Admins, but not with the
> >>> other groups.
> >>>
> >>> jp
> >>>
> >>> "Joan Wild" wrote:
> >>>
> >>>> You may find it easier if you create your own unbound form for your
> >>>> switchboard.  It is more flexible than the built-in switchboard
> >>>> manager, especially for something like this.
> >>>>
> >>>> There is code in the security FAQ you can use to determine if a
> >>>> user is member of a group.
> >>>>
> >>>> Then in the open event of your menu form you'd use...
> >>>>
> >>>> If faq_IsUserInGroup("ReadOnly",CurrentUser) then
> >>>>     Me.cmdWhatever.Visible = False
> >>>>     Me.cmdSomething.Visible = True
> >>>> etc.
> >>>> Else
> >>>>     Me.cmdWhatever.Visible = True
> >>>>     Me.cmdSomething.Visible = True
> >>>> etc.
> >>>> End If
> >>>>
> >>>> The FAQ can downloaded from
> >>>>  http://support.microsoft.com/?id=207793
> >>>>
> >>>>
> >>>> --
> >>>> Joan Wild
> >>>> Microsoft Access MVP
> >>>>
> >>>> bigpalooka wrote:
> >>>>> With my split, multi-user, secured Access 2000 db, I have 3 user
> >>>>> groups - Admins, Read-Only, and Full-User (built-in groups).  I'd
> >>>>> like to disable or hide some command buttons I have on my
> >>>>> switchboard - "User Maintenance", and "Change Password" for all
> >>>>> but Admins.  I have code that finds out which group the logged-in
> >>>>> user belongs to, but it doesn't allow the non-Admin users to run
> >>>>> it: strUserLevel =
> >>>>> Workspaces(0).Users(Workspaces(0).UserName).Groups(0).Name
> >>>>> so I can't hide or show objects based on the user level.
> >>>>> - Is this by design, or is there a way to do this?
>
>
>
Author
17 Nov 2006 3:33 AM
bigpalooka
OK - I removed all security, imported everything into a new db and reset the
security and it all works like a champ.  Something got corrupted somewhere
and I couldn't recover from it.  I've since recovered and am doing well.

Show quoteHide quote
"bigpalooka" wrote:

> With my split, multi-user, secured Access 2000 db, I have 3 user groups -
> Admins, Read-Only, and Full-User (built-in groups).  I'd like to disable or
> hide some command buttons I have on my switchboard - "User Maintenance", and
> "Change Password" for all but Admins.  I have code that finds out which group
> the logged-in user belongs to, but it doesn't allow the non-Admin users to
> run it:
> strUserLevel = Workspaces(0).Users(Workspaces(0).UserName).Groups(0).Name
> so I can't hide or show objects based on the user level.
> - Is this by design, or is there a way to do this?
Author
17 Nov 2006 2:48 PM
Joan Wild
Thanks for the followup.

--
Joan Wild
Microsoft Access MVP

bigpalooka wrote:
Show quoteHide quote
> OK - I removed all security, imported everything into a new db and
> reset the security and it all works like a champ.  Something got
> corrupted somewhere and I couldn't recover from it.  I've since
> recovered and am doing well.
>
> "bigpalooka" wrote:
>
>> With my split, multi-user, secured Access 2000 db, I have 3 user
>> groups - Admins, Read-Only, and Full-User (built-in groups).  I'd
>> like to disable or hide some command buttons I have on my
>> switchboard - "User Maintenance", and "Change Password" for all but
>> Admins.  I have code that finds out which group the logged-in user
>> belongs to, but it doesn't allow the non-Admin users to run it:
>> strUserLevel =
>> Workspaces(0).Users(Workspaces(0).UserName).Groups(0).Name
>> so I can't hide or show objects based on the user level.
>> - Is this by design, or is there a way to do this?