scottetombleson
Programmer
How do you check the current users group membership before an action? I can't find the code for this anywhere. Thanks in advance for any help.
Scott
Scott
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 GetCurrentUserGroups() As String
Dim wrk As Workspace
Dim usr As User
Dim grp As Group
Dim strGroups As String
On Error Resume Next
Set wrk = DBEngine.Workspaces(0)
Set usr = wrk.Users(Application.CurrentUser)
For Each grp In usr.Groups
strGroups = strGroups & grp.Name & ","
Next grp
GetCurrentUserGroups = Left(strGroups, InStrRev(strGroups, ",") - 1)
End Function
Function InGroup(ByVal strGroup As String) As Boolean
Dim varGroups As Variant
Dim i As Integer
varGroups = Split([blue]GetCurrentUserGroups()[/blue], ",")
For i = 0 To UBound(varGroups)
If UCase(varGroups(i)) = UCase(strGroup) Then
InGroup = True
Exit For
End If
Next i
End Function