Get Current User Group in VBA

JenSGT

Registered User.
Local time
Today, 01:58
Joined
Jul 26, 2009
Messages
20
I know CurrentUser is able to display the current username. How do you display the current User's group in VBA?

If a User belongs to at least 2 groups, will VBA be able to detect which is the default group?

Thx for any code tips...
 
Are you referring to User Level Security in Access or Active Directory?
 
i think you have to use dao to read the group access.

there is no default group - the users privileges are the cumulation of all the groups of which he is a member. so if group1 just has R privileges for a form, but group2 has RWD privildges, a user in both group1 and group2 will have RWD privileges for that form.
 
I am referring to Access User Level Security.
 
i think you have to use dao to read the group access.

there is no default group - the users privileges are the cumulation of all the groups of which he is a member. so if group1 just has R privileges for a form, but group2 has RWD privildges, a user in both group1 and group2 will have RWD privileges for that form.


How do I use dao to read the group access? any code tips?
 
Hi, I don't know if you found the solution to your question but I had the same problem and I wrote this code based on an example inside Access help section. It's a little bit long for the result but provide the result that I want. The code look for each user and verify to what group a particular user belong.

I hope this code can help you.

Private Sub CHKGroup()
Dim wks As Workspace
Dim Usr As User
Dim Grp As Group
Dim ActualUsr, ActualGrp As String
Set wks = DBEngine.Workspaces(0)
With wks

'Compare all users within the workgroup with the current user
For Each Usr In .Users
'If the current user = user found within workgroup then verify to what group this user belong
If CurrentUser() = Usr.Name Then
If Usr.Groups.Count <> 0 Then
For Each Grp In Usr.Groups
'Select Case for each group found
Select Case Grp.Name
Case "Admins"
'Call Admins procedure
Debug.Print Grp.Name
'End sub
Case "Users"
'Call Users procedure
Debug.Print Grp.Name
'End sub
End Select
Next Grp
End If
End If
Next Usr

End With
End Sub
 
Last edited:
but to repeat - there is no such thing/concept of a default group
 

Users who are viewing this thread

Back
Top Bottom