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
VBSlammer
"You just have to know which screws to turn." - Professor Bob
You can use the previous function along with this one to see if the current user is in a particular group:
Example:
[tt]
If InGroup("Admins") Then
[green]'allow admin task[/green]
End If[/tt]
Code:
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
VBSlammer
"You just have to know which screws to turn." - Professor Bob
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.