Solved

ms Access

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Access 2016 7 33
Auto-generated ID's in MS Access 9 45
Why can't I update my query in datasheet view (or my form). 6 20
Question about DB Schema 27 52
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
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.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

776 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