Solved

ms Access

Posted on 2016-08-02
6
58 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
6 Comments
 
LVL 36

Expert Comment

by:PatHartman
ID: 41739488
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
ID: 41739523
I mean Access security Group accounts.
i want to know which group a user belongs.
0
 
LVL 36

Expert Comment

by:PatHartman
ID: 41739600
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 26

Expert Comment

by:Nick67
ID: 41739716
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
ID: 41750897
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
ID: 41776804
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
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…

749 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