Function IsUserInGroup(UserName As String, GroupName As String) As Boolean
'/Purpose:
'/Created: 12/11/2008 09:45 AM
'/Created By: Scott
Dim usr As DAO.User
On Error GoTo Err_IsUserInGroup
Set usr = DBEngine.Workspaces(0).Groups(GroupName).Users(UserName)
IsUserInGroup = True
Exit_IsUserInGroup:
On Error Resume Next
Set usr = Nothing
Exit Function
Err_IsUserInGroup:
Select Case Err
Case 3265
'/either the group doesn't exist, or it does but the User isn't a member.
'/either way, we return False
Case Else
MsgBox "An error occurred in this application." & vbCrLf & vbCrLf & Err & ":" & Error$ & vbCrLf & vbCrLf & "Technical Information: Occurred in [Module1].[IsUserInGroup]", vbCritical, "Application Error"
End Select
Resume Exit_IsUserInGroup
End Function
|