Open form based on group

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am wondering if there is a way to make access 2003 open a form based on
what group you are in. I know I can do this per each user, but if there was a
way for access to check which group the user was in that would make it
easier. Example would be if the user is in the admins group then open this
form else open this other form. Thanks for the help.
 
Jragan said:
I am wondering if there is a way to make access 2003 open a form
based on what group you are in. I know I can do this per each user,
but if there was a way for access to check which group the user was
in that would make it easier. Example would be if the user is in the
admins group then open this form else open this other form. Thanks
for the help.

I assume you're talking about users and groups as established by
user-level (workgroup) security. Since a user can be in more than one
group, you can't really check to see what group (singular) a user is in,
but you can get a list of the groups a user is in, and you can check to
see if a user is in a particular group. See the two functions I've
posted below:

'------ start of code ------
Function fncUserIsInGroup(GroupName As String) As Boolean

' Returns True if the current user is a member of the specified
' security group; False if not, or if the group doesn't exist, or
' if an error occurs reading the groups.

Dim ws As Workspace

Set ws = DBEngine.Workspaces(0)

On Error Resume Next
fncUserIsInGroup = _
(ws.Users(CurrentUser).Groups(GroupName).Name = GroupName)

Set ws = Nothing

End Function

Function fncUserGroups() As String

' Returns a comma-separated list of the security groups of which
' the current user is a member.

Dim ws As DAO.Workspace
Dim grp As DAO.Group
Dim strGroups As String

Set ws = DBEngine.Workspaces(0)

For Each grp In ws.Users(CurrentUser).Groups
strGroups = strGroups & ", " & grp.Name
Next grp

Set ws = Nothing

fncUserGroups = Mid(strGroups, 3)

End Function
'------ end of code ------
 
Back
Top