Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2003
    Posts
    46

    Question Unanswered: Detect User Group - how?

    Hi All,

    Working on database with User-Level security and want to define startup properties based on the User Group of the logged in user (ie. If user group A open form FormA, If user group B open form FormB etc.). I know I can use currentuser() to recognise a specific user but how do I recognise the group?

    If anyone out there has done anything like this before - your help would be much appreciated )
    Regards
    C

  2. #2
    Join Date
    Mar 2003
    Location
    Romania
    Posts
    32
    You can use this function:

    Function MatchUserGroup(strUser As String, strGroup As String) As Boolean
    Dim wrkDefault As Workspace
    Dim grpLoop As Group

    MatchUserGroup = False
    Set wrkDefault = DBEngine.Workspaces(0)
    For Each grpLoop In wrkDefault.Users(strUser).Groups
    If grpLoop.Name = strGroup Then
    MatchUserGroup = True
    Exit For
    End If
    Next
    End Function

    You can use it like this:
    if MatchUserGroup(CurrentUser(),"GroupA") then
    docmd.OpenForm "FormA"
    endif
    Florin Profeanu
    floreanuprofin@yahoo.com

  3. #3
    Join Date
    Mar 2003
    Posts
    46
    Thank you, thank you, thank you! Works an absolute treat, hurrah!

    C

  4. #4
    Join Date
    Apr 2004
    Posts
    100
    Hello,

    your solution works fine if one uses DAO, however I am using ADO. So is there a way to do it in ADO?

    Thanks !

Posting Permissions

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