How to list users

E

Eileen

I have a form that allows you to change a user password if you are part of the administrators group.

On the form it requires you to enter a user name in the field I want to make this a drop down box with a list of users that are part of the workgroup and for the life of me can't figure it out.

Any help would greatly be appreciated.
 
J

Jon Lewis

Search Help for "RowSourceType Property (User-Defined Function)". This will
show you how to create a function to programmatically fill a combobox
rowsource. Alternatively you can just use a rowsourcetype of Value List and
construct a string for the rowsource in the open event of your form.

You can iterate through your workgroup users as follows:

Dim MyWorkSpace As Workspace, MyUser As User
Set MyWorkSpace = DBEngine.Workspaces(0)
For Each MyUser In MyWorkSpace.Users
Debug.Print MyUser.Name
Next MyUser
Set MyWorkSpace = Nothing

This will include the default Admin, Engine, Creator names so you need to
add additional logic to skip those

HTH

I have a form that allows you to change a user password if you are part of
the administrators group.

On the form it requires you to enter a user name in the field I want to make
this a drop down box with a list of users that are part of the workgroup and
for the life of me can't figure it out.

Any help would greatly be appreciated.
 
J

Jon Lewis

Meant to add:
If you just want the administrators in the list

Dim MyWorkSpace As Workspace, MyUser As User, GrpU As Group
Set MyWorkSpace = DBEngine.Workspaces(0)
Set GrpU = MyWorkSpace.Groups("Admins")
For Each MyUser In GrpU.Users
Debug.Print MyUser.Name
Next MyUser
Set GrpU = Nothing
Set MyWorkSpace = Nothing

HTH
I have a form that allows you to change a user password if you are part of
the administrators group.

On the form it requires you to enter a user name in the field I want to make
this a drop down box with a list of users that are part of the workgroup and
for the life of me can't figure it out.

Any help would greatly be appreciated.
 
P

Pieter Wijnen

You can build a rowsource like this as well

Function GetWsUsers() As String
Dim thQ As String
thQ = "SELECT Name From MSysAccounts A" & VBA.VbCrlf & _
"IN '" & SyScmd(acSysCmdWorkGroupFile) & "'" & VBA.vbCrlf & _
"WHERE A.FGROUP=0"

GetWsUsers=thQ

End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top