Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2004
    Location
    Glasgow, Scotland
    Posts
    107

    Unanswered: Access Security - Groups - VBA Code

    Hi,

    I am using an Access Workgroup file for one of my databases. I would like to use VBA to determine the username of the user currently logged into the database and also the names of the groups the user is attached to. Does anyone have any sample code they could show me??

    Ta
    Matt

  2. #2
    Join Date
    Oct 2003
    Location
    US
    Posts
    343
    Quote Originally Posted by mmcdonald
    Hi,

    I am using an Access Workgroup file for one of my databases. I would like to use VBA to determine the username of the user currently logged into the database and also the names of the groups the user is attached to. Does anyone have any sample code they could show me??

    Ta
    Matt

    Use CurrentUser() to get the user currently looged in. Use the following function and pass the currentuser to it.

    Public Sub test21(inUser As String)
    Dim wrkspc As Workspace
    Dim usr As User
    Dim grp As Group

    Set wrkspc = DBEngine.Workspaces(0)

    For Each grp In wrkspc.Groups
    For Each usr In grp.Users
    If usr.Name = inUser Then
    Debug.Print grp.Name
    End If
    Next usr
    Next grp
    End Sub

  3. #3
    Join Date
    Mar 2004
    Location
    Glasgow, Scotland
    Posts
    107
    Thanks for the reply but I've already cracked it, should've posted, sorry.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •