Solved

ms Access

Posted on 2016-08-02
6
56 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 35

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 35

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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Suggested Solutions

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
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…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

860 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