Admin always shows up as a user

S

Simon Cleal

Im using the following snipet of code to populate a combo box with a list of
user IDs...

Dim objWorkSpace As Workspace
Set objWorkSpace = DBEngine.CreateWorkspace _("SPECIAL", "AdminUser",
"AdminPassword")
intCount = 0
cmbUserID.RowSource = objWorkSpace.Users(intCount).Name
For intCount = 1 To objWorkSpace.Users.Count - 1
Select Case objWorkSpace.Users(intCount).Name
Case "Creator", "Engine", "admin", "Admin" '***
Case Else
cmbUserID.RowSource = cmbUserID.RowSource & ";" & _
objWorkSpace.Users(intCount).Name
End Select
Next intCount
objWorkSpace.Close
Set objWorkSpace = Nothing


The line of code I've marked with *** is designed to prevent the user from
seeing any userIDs I feel would 'confuse' them (it doesnt take much to
'confuse' my users!)

Despite that line of code a User ID called admin (but not Engine or Creator)
always comes up in the combo box!

Can anyone explain why and how I can get rid of it?

Thanks in advance

Simon
 
T

TC

Urk! I stopped on the createworkspace. You do not need to create a
worksace, to get the list of current users & groups in the current
workgroup file.

This will do it:

dim u as user
for each u in dbengine(0).users
msgbox u.name
next

I suggest that you rewrite your snippet, then try again.

Note that normal VBA comparisons are case insensitive. You don't need
to check "admin" /and/ "Admin" - either one will do (though for
readability, I always code as if the tests /are/ case sensitive).

HTH,
TC
 
S

Simon Cleal

Thanks TC Ive revised my code, Ive also spotted my "delibarate" mistake lol
 

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