This function will return a String with all Groups and the users assigned to those Groups:
Function PrintUsersGroups(Optional PrintoutPath As String) As String
Dim usr As DAO.User
Dim grp As DAO.Group
Dim ws As DAO.Workspace
Dim strOutput As String
Dim lngFile As Long
Set ws = DBEngine(0)
For Each grp In ws.Groups
strOutput = strOutput & grp.Name
strOutput = strOutput & vbCrLf & "-------------"
For Each usr In grp.Users
strOutput = strOutput & vbCrLf & usr.Name
Next usr
strOutput = strOutput & vbCrLf & vbCrLf
Next grp
PrintUsersGroups = strOutput
If Len(PrintOut)>0 Then
lngFile = FreeFile
Open Printout For Output As #lngFile
Write #lngFile, strOutput
Close #lngFile
End If
Set ws = Nothing
End Function
You could then use this in a MsgBox like this:
Msgbox PrintUsersGroups
or, if you wanted to print to a Text file:
PrintUserGroups(CurrentProject.Path & "\Users_And_Groups.txt")
Scott McDaniel
scott@takemeout_infotrakker.com
www.infotrakker.com