Solved

ms Access

Posted on 2016-08-02
6
60 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 38

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 38

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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
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

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!

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
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.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

719 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