Results 1 to 2 of 2
  1. #1
    Star Lounger
    Join Date
    Mar 2004
    Location
    White Oak, Pennsylvania, USA
    Posts
    94
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Group Membership (Access 2002)

    I am working on an Access form on which there are tabs, one of which I only want to appear for members of a certain group.

    How can I programatically access which group the logged-in user is a member of?

  2. #2
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Group Membership (Access 2002)

    Here is a function that will determine wehther the current user is a member of a specified group.

    <pre>Public Function fnIsGroupMember(strGroupName As String) As Boolean
    Dim wks As Workspace
    Dim grp As Group
    Dim usr As User
    Dim boolinGroup As Boolean
    boolinGroup = False
    Set wks = DBEngine.Workspaces(0)
    Set grp = wks.Groups(strGroupName)


    For Each usr In grp.Users
    If usr.Name = CurrentUser Then
    boolinGroup = True
    End If
    Next usr
    fnIsGroupMember = boolinGroup
    End Function
    </pre>


    You could use it in the onload event for the form, and you need to pass it the name of the group.

    e.g.

    if fnisGroupMember("mygroup") then
    me!page2.visible =true
    else
    me!page2.visible=false
    end id
    Regards
    John



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •