View users in database

  • Thread starter ladybug via AccessMonster.com
  • Start date
L

ladybug via AccessMonster.com

I used the following code in a module:

Sub ShowUserRosterMultipleUsers()
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim i, j As Long

Set cn = CurrentProject.Connection

' The user roster is exposed as a provider-specific schema rowset
' in the Jet 4.0 OLE DB provider. You have to use a GUID to
' reference the schema, as provider-specific schemas are not
' listed in ADO's type library for schema rowsets

Set rs = cn.OpenSchema(adSchemaProviderSpecific, _
, "{947bb102-5d43-11d1-bdbf-00c04fb92675}")

'Output the list of all users in the current database.

Debug.Print rs.Fields(0).Name, "", rs.Fields(1).Name, _
"", rs.Fields(2).Name, rs.Fields(3).Name

While Not rs.EOF
Debug.Print rs.Fields(0), rs.Fields(1), _
rs.Fields(2), rs.Fields(3)
rs.MoveNext
Wend

End Sub

I then have ShowUserRosterMultipleUsers in the Immediate Window. When I run
this the line cn As New ADODB.Connection in the code above is highlighted and
I receive a compile error, which states user-defined type not defined.

Can someone help me? I do not know vb or modules. Thank you!
 
D

Douglas J. Steele

Do you have a reference set to ADO? Assuming you're using Access 2003 or
earlier, go into the VB Editor, select Tools | References from the menu and
make sure there's a checked reference at the top of the list to Microsoft
ActiveX Data Objects 2.x Object Library (your choice for what x is!) and
that it's not marked "MISSING:"
 

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

Similar Threads


Top