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开发者_StackOverflow中文版 to from the user, but there must be a cleaner way to do this.
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
精彩评论