Here is a late binding example based on the KB article Allen referenced...no
reference required:
Sub ShowUserRosterMultipleUsers()
Dim cn As Variant 'New ADODB.Connection
Dim cn2 As Variant 'As New ADODB.Connection
Dim rs As Variant 'As New ADODB.Recordset
Dim i, j As Long
Set cn = CreateObject("ADODB.Connection")
' Set cn2 = CreateObject("ADODB.Connection")
cn.Provider = "Microsoft.Jet.OLEDB.4.0"
cn.Open "Data Source=" & CurrentDb.Name
' cn2.Open "Provider=Microsoft.Jet.OLEDB.4.0;" _
' & "Data Source=" & CurrentDb.Name
' The user roster is exposed as a provider-specific schema rowset
' in the Jet 4 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(-1, _
, "{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
Note the count will be off by at least one (1), because you're creating a
connection in the code...plus whatever DAO instance you already have. The
original sample was off by two (2) because of the 2 connections it created.