Question

How can I find a list of all the MS Access security groups in my application through VBA?

I know I can do it by going to Tools->Security->User and Group accounts, but I'd like to do it through VBA (I'd like to automate some of my user creation routine).

I've considered adding a dummy user that is assigned to all the groups and just pulling the groups they are assigned to from the user, but there must be a cleaner way to do this.

Was it helpful?

Solution

Found it!

Dim curr_group As Group
Dim group_cnt As Long
Dim group_ndx As Long

Dim strGroup As String
Dim strGroupList As String

    strGroupList = ""
    group_cnt = DBEngine(0).Groups.Count
    For group_ndx = 0 To group_cnt - 1
        Set curr_group = DBEngine(0).Groups(group_ndx)
        strGroup = curr_group.Name
        If strGroupList = "" Then
            strGroupList = strGroup
        Else
            strGroupList = strGroupList & ";" & strGroup
        End If
    Next group_ndx
    Me.lbxSysGroups.RowSource = strGroupList
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top