Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Function UserBelongsToGroup(strGroupName As String, _
Optional varCurrentUser As Variant) As Boolean
'********************************
'* Declaration Specifications *
'********************************
Dim wsp As DAO.Workspace
Dim grp As DAO.Group
Dim usr As DAO.User
Dim strCurrentUser As String
'****************
'* Initialize *
'****************
On Error GoTo ErrHandler
If (IsMissing(varCurrentUser)) Then
strCurrentUser = CurrentUser
Else
strCurrentUser = CStr(varCurrentUser)
End If
Set wsp = DBEngine.Workspaces(0)
Set grp = wsp.Groups(strGroupName)
'******************************************************************
'* Loop to determine if the User is part of the group specified *
'******************************************************************
For Each usr In grp.Users
If (usr.Name = CurrentUser) Then UserBelongsToGroup = True: GoTo ExitProcedure
Next
UserBelongsToGroup = False
'********************
'* Exit Procedure *
'********************
ExitProcedure:
On Error Resume Next
wsp.Close
Set wsp = Nothing
Set grp = Nothing
Exit Function
'****************************
'* Error Recovery Section *
'****************************
ErrHandler:
If Err = 3265 Then
Err.Raise Err.Number, "UserBelongsToGroup", """" & UCase(strGroupName) & """ isn't a valid group account."
ElseIf Err = 3029 Then
Err.Raise Err.Number, "UserBelongsToGroup", "The account used to create the workspace does not exist."
Else
Err.Raise Err.Number, "UserBelongsToGroup", Err.Description
End If
End Function
Function UserBelongsToGroup(Optional varCurrentUser As Variant)
'********************************
'* Declaration Specifications *
'********************************
Dim wsp As DAO.Workspace
Dim grp As DAO.Group
Dim usr As DAO.User
Dim strCurrentUser As String
'****************
'* Initialize *
'****************
On Error GoTo ErrHandler
If (IsMissing(varCurrentUser)) Then
strCurrentUser = CurrentUser
Else
strCurrentUser = CStr(varCurrentUser)
End If
Set wsp = DBEngine.Workspaces(0)
For Each grp In wsp.Groups
MsgBox grp.Name
Next
'********************
'* Exit Procedure *
'********************
ExitProcedure:
On Error Resume Next
wsp.Close
Set wsp = Nothing
Set grp = Nothing
Exit Function
'****************************
'* Error Recovery Section *
'****************************
ErrHandler:
MsgBox Err.Number & Err.Description
Resume ExitProcedure
End Function