Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2007
    Posts
    15

    Unanswered: List of Access Users

    Is it possiable to get a list of user names that have been entered into Access? I other words is it possiable with a function/method/sql call to get the list of user on the Users tab that is on the drop down menu in
    Tools->Security->Users and Groups Accounts ??

    I would like to take the list of users and put them on a drop down menu on a form.

    Thanks for the help...

  2. #2
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926

    Users in an mdw

    If you've established an mdw file, you can use this utility which let's you see all the users/passwords for a selected mdw file. Not sure about how you would incorporate this into a drop down menu on a form though. There might be some vba code someone has which will do the same type of thing.
    Attached Files Attached Files
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  3. #3
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    if you can query it or iterate through the collection then you can stuff the results into a list box

    so you can iterate through the relevant object and shove each required property into a relevant list box.

    I've interated through the workgroup file in the past to show users, which groups they belong to.

    We had a big sitewide workgroup file, and I didn't want the users of this app to edit it directly, so I designed a variant on the workgroup administrator from which allowed admin users to add users or add/change/delete a users membership of groups or granting of permissions. the form also enforced certain criteria.. ie always keeping at least one administrator for that app. it also always made sure that the get out of jail userid was always in the workgroup file, irrespective of what users actually did.
    I'd rather be riding on the Tiger 800 or the Norton

  4. #4
    Join Date
    Aug 2007
    Posts
    15

    Need code

    pkstormy: The utility you attached is doing very close to what I need. Do you have any source code. Does any one have VBA code that can get a list of users in the dbw file? Do not need pass words just user name.

  5. #5
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    Sorry - I don't have the source code for the utility I uploaded. I downloaded it from one of the websites (I can't recall which one but you may want to google Access Security, mdw, etc..).
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  6. #6
    Join Date
    Aug 2007
    Posts
    15

    I found my own solution

    In the Object Browser...
    Under the Users Collection...
    In Example...
    Under CreateUser Method and Password and PID Properties Example...

    there is sample code that will list all the users and all sorts of info about which group they are in and other info. See below. Enjoy...

    Sub CreateUserX(ByRef strPassword As String)

    Dim wrkDefault As Workspace
    Dim usrNew As User
    Dim grpNew As Group
    Dim usrTemp As User
    Dim prpLoop As Property
    Dim grpLoop As Group

    Set wrkDefault = DBEngine.Workspaces(0)

    With wrkDefault

    ' Create and append new User.
    Set usrNew = .CreateUser("NewUser")
    usrNew.PID = "AAA123456789"
    usrNew.Password = strPassword
    .Users.Append usrNew

    ' Create and append new Group.
    Set grpNew = .CreateGroup("NewGroup", _
    "AAA123456789")
    .Groups.Append grpNew

    ' Make the user "NewUser" a member of the
    ' group "NewGroup" by creating and adding the
    ' appropriate User object to the group's Users
    ' collection.
    Set usrTemp = _
    .Groups("NewGroup").CreateUser("NewUser")
    .Groups("NewGroup").Users.Append usrTemp

    Debug.Print "Properties of " & usrNew.Name

    ' Enumerate the Properties collection of NewUser. The
    ' PID property is not readable.
    For Each prpLoop In usrNew.Properties
    On Error Resume Next
    If prpLoop <> "" Then Debug.Print " " & _
    prpLoop.Name & " = " & prpLoop
    On Error GoTo 0
    Next prpLoop

    Debug.Print "Groups collection of " & usrNew.Name

    ' Enumerate the Groups collection of NewUser.
    For Each grpLoop In usrNew.Groups
    Debug.Print " " & _
    grpLoop.Name
    Next grpLoop

    ' Delete the new User and Group objects because this
    ' is a demonstration.
    .Users.Delete "NewUser"
    .Groups.Delete "NewGroup"

    End With

    End Sub

  7. #7
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    Thanks for supplying what you found GetAJob! It's very nice when people post their solutions and this is some handy code to have.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

Posting Permissions

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