Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting user lists fron workgroup

Status
Not open for further replies.

DickiePotter

Programmer
Jan 8, 2001
30
0
0
GB
Hi,
I am tring to get a list of all the user names in the workgroup file and put them in a field in the database that is being secured by it. How can I do this?

If I cannot enter the values directly as records then can I use the usernames in a lookup for a combo box or list box?

Please help, this has been bugging me for weeks.
It's also a piece of coarsework and is therefor rather urgent!!!

Thanks,
 
You can access all the users (and groups) in the workgroup file using DAO. You need to set a Workspace object variable to the default workspace. Then loop through its Users collection and process each User object. The Name property contains the user name.

I'd write the code for you, but since this is coursework you need to do that yourself. Rick Sprague
 
Please write the code, please, please...
I never use other peoples code without making sure I fully understand it anyway, so it's far from cheating!
Come-on be a sport
:)
 
Code:
    Dim db As Database, wsp As Workspace, usr As User
    Dim rst As Recordset

    Set db = CurrentDb()
    Set rst = db.OpenRecordset("UserNames", dbOpenTable)
    Set wsp = db.Workspaces(0)
    For Each usr In wsp.Users
        rst.AddNew
        rst!Name = usr.Name
        rst.Update
        rst.MoveNext
    Next usr
    rst.Close
    Set rst = Nothing
    Set wsp = Nothing
    Set db = Nothing
Just to make sure you really do "fully understand it", the code above contains a bug. As long as you understand what all of it is doing, it shouldn't be hard to find. :) Rick Sprague
 
He He
The ! was an interesting fault,
Thank-You for the code
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top