Different menus depending on security group?

  • Thread starter Thread starter Steve W.
  • Start date Start date
S

Steve W.

Re: Different menus depending on security group?

I would like to offer users of our production management
database different menus depending on which security group
they belong to.

Is there a function or other way to determine which
security group a user is logged in as, and use it to
control programming?

Steve W.

[also posted under Forms Programming]
 
Hi Steve

First, please do not post the same message *separately* to different groups.
If it's appropriate, you can cross-post, which means you post to multiple
groups *at the same time*. This way, you can see the entire thread -
questions and answers - in any of the newsgroups, no matter where the
answers were posted from.

Now, to answer your question :-)

The following function will tell you whether of not a given user (the
current user by default) is in a given group:

Function IsUserInGroup(strGroup As String, _
Optional strUser As String) As Boolean
Dim usr As Object
On Error Resume Next
If Len(strUser) = 0 Then strUser = CurrentUser
Set usr = DBEngine(0).Groups(strGroup).Users(strUser)
IsUserInGroup = Err = 0
End Function

You can then say something like:
If IsUserInGroup("Sales_Staff") Then ...

Whether you are using form-based (switchboard) menus or command bar menus,
you can then use your code to make certain options visible or not, according
to group membership.
 
Further to Graham's reply: Then use methods of the Commandbars object to
show/hide menus as required. Check out Commandbars in the online help.

Notice also that a user can be a member of >several< groups. User to group
is not "many to one", it is "many to many".

HTH,
TC



Graham Mandeno said:
Hi Steve

First, please do not post the same message *separately* to different groups.
If it's appropriate, you can cross-post, which means you post to multiple
groups *at the same time*. This way, you can see the entire thread -
questions and answers - in any of the newsgroups, no matter where the
answers were posted from.

Now, to answer your question :-)

The following function will tell you whether of not a given user (the
current user by default) is in a given group:

Function IsUserInGroup(strGroup As String, _
Optional strUser As String) As Boolean
Dim usr As Object
On Error Resume Next
If Len(strUser) = 0 Then strUser = CurrentUser
Set usr = DBEngine(0).Groups(strGroup).Users(strUser)
IsUserInGroup = Err = 0
End Function

You can then say something like:
If IsUserInGroup("Sales_Staff") Then ...

Whether you are using form-based (switchboard) menus or command bar menus,
you can then use your code to make certain options visible or not, according
to group membership.

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Steve W. said:
Re: Different menus depending on security group?

I would like to offer users of our production management
database different menus depending on which security group
they belong to.

Is there a function or other way to determine which
security group a user is logged in as, and use it to
control programming?

Steve W.

[also posted under Forms Programming]
 
Back
Top