Solved

ms Access

Posted on 2016-08-02
6
45 Views
Last Modified: 2016-09-04
Hello All,

How can I find out the group name of a user? (In code)
Thanks
0
Comment
Question by:frimy
  • 2
  • 2
  • 2
6 Comments
 
LVL 34

Expert Comment

by:PatHartman
Comment Utility
What is "group name"?

You can use the Environ() function to find out the user logged into the computer or the computer name.

strUser = Environ("UserName")

If you are using your own security as I do, then instead of closing the log in form, hide it.  That will allow you to reference the login form whenever you need the user name of the logged in user.
0
 

Author Comment

by:frimy
Comment Utility
I mean Access security Group accounts.
i want to know which group a user belongs.
0
 
LVL 34

Expert Comment

by:PatHartman
Comment Utility
Access hasn't fully supported ULS since A2003 was replaced with A2007 which was 9 years ago.  I have erased most information regarding the details of ULS from memory.  Time to implement your own security and stop using ULS so you can move to the .accdb format.

I attached the text of a post along with it's link.  This was the only reference I found that used VBA to do anything with ULS.  It may give you direction.
ReadSystemMDW.docx
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 26

Expert Comment

by:Nick67
Comment Utility
Do you mean Active Directory?
You can get information out of Active Directory via VBA.
Most users belong to many AD groups, though.
0
 

Author Comment

by:frimy
Comment Utility
I already found what I wanted and I changed it a little for my needs.
Thank you all

Function IsUserInGroup(strUser As String, strGroup As String) As Boolean
   
    'Returns True if the user is in the group.
    'Example: IsUserInGroup(CurrentUser(), "Admins")
    Dim wk As Workspace, grx As Groups, grp As Group, usx As Users, usr As User
    Dim wFoundSw As Integer
   
    Set grx = DBEngine(0).Groups
    For Each grp In grx
        If wFoundSw = 1 Then Exit For
        If grp.Name = strGroup Then
           Set usx = grp.Users
           For Each usr In usx
               If usr.Name = strUser Then
                  IsUserInGroup = True
                  wFoundSw = 1
                  Exit For
               End If
           Next
       End If
    Next

    Set usr = Nothing: Set usx = Nothing: Set grp = Nothing: Set grx = Nothing
   
End Function
0
 
LVL 26

Accepted Solution

by:
Nick67 earned 500 total points
Comment Utility
Hey @frimy!
Is this one complete?
You can close it by accepting your comment as the best solution and then assigning points.

Nick67
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now