And then this one just determines if the user is a member of a certain group.
Public Function UserIsMemberOfGroup(strUsr As String, strGrp As String) As Boolean
' This function determines the groups the current user is assigned
' and returns true if the user is a member of the group being
' tested by the parameter strGrp
' Parameters:
' strUsr is a string value for the user to test
' strGrp is a string value for a valid group
Dim wsp As Workspace
Dim dbs As Database
Dim usr As User
Dim grp As Group
Dim strGrps As String
On Error GoTo HandleErr
' Return reference to default workspace.
Set wsp = DBEngine.Workspaces(0)
' Return reference to current database.
Set dbs = CurrentDb
' Set User object to the CurrentUser
Set usr = wsp.Users(strUsr)
For Each grp In usr.Groups
If grp.Name = strGrp Then
UserIsMemberOfGroup = True
GoTo Proc_Exit
End If
DocSkip:
Next grp
Proc_Exit:
Set wsp = Nothing
Set dbs = Nothing
Set usr = Nothing
Set grp = Nothing
Exit Function
HandleErr:
Select Case Err.Number
Case 3033 ' No Permissions
mstrErrors = mstrErrors & PadErrNumber(Err.Number) & "," & Err.Description & ";"
GoTo DocSkip
Case Else
Call HandleTheError("basPermissions", "UserIsMemberOfGroup", Err, ShowMsg)
End Select
Resume Proc_Exit
Resume
End Function
Steve King Growth follows a healthy professional curiosity