Display users from user and group accounts in a combo box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • phill86
    New Member
    • Mar 2008
    • 121

    Display users from user and group accounts in a combo box

    Hi,

    I have a form that stamps the underlying table with the current user when a record is created.

    I want to be able to run a report by selecting the users that are in the group/user acounts so i need to be able to display the users that have been set up in the user/group accounts in a combo box

    Is there anyway of doing this?

    Regards Phill
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    Originally posted by phill86
    Hi,

    I have a form that stamps the underlying table with the current user when a record is created.

    I want to be able to run a report by selecting the users that are in the group/user acounts so i need to be able to display the users that have been set up in the user/group accounts in a combo box

    Is there anyway of doing this?

    Regards Phill
    Is there anyway of doing this?
    Yes there is, I'll return later with some sample code for you.

    Comment

    • ADezii
      Recognized Expert Expert
      • Apr 2006
      • 8834

      #3
      Originally posted by phill86
      Hi,

      I have a form that stamps the underlying table with the current user when a record is created.

      I want to be able to run a report by selecting the users that are in the group/user acounts so i need to be able to display the users that have been set up in the user/group accounts in a combo box

      Is there anyway of doing this?

      Regards Phill
      Hello Phil, create a Combo Box on your Form and Name it cboGroupsAndUse rs, the code will do the rest. The following code will populate a 2-Column Combo Box with a List of all Groups and Users assigned to those Groups. Be advised that a Group may/may not consist of many Users, and a User can be a Member of 1 or more Groups:
      Code:
      Dim wrk As DAO.Workspace
      Dim grp As DAO.Group
      Dim usr As DAO.User
      Dim strBuild As String
      
      'To define Column Headers
      strBuild = "Groups;Users;"
      
      Set wrk = DBEngine.Workspaces(0)
      
      With Me![cboGroupsAndUsers]
        .ColumnCount = 2
        .RowSourceType = "Value List"
        .ColumnHeads = True
      
        For Each grp In wrk.Groups
          For Each usr In grp.Users
            strBuild = strBuild & grp.Name & ";" & usr.Name & ";"
          Next
        Next
      
        .RowSource = Left$(strBuild, Len(strBuild) - 1)
      End With
      
      Set usr = Nothing
      Set grp = Nothing
      
      wrk.Close
      Set wrk = Nothing

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32661

        #4
        It may also help to consider that Users and Groups (at least in their current form) will probably be discontinued in future versions (if not already removed in A2007).

        Comment

        Working...