Show Users Button

P_DUBS

New member
Local time
Today, 03:49
Joined
Jul 30, 2008
Messages
8
Good morning,

I am attempting to add a button to the front of my database that will produce a message box listing the current users. I have attached the following code to a button but the message box is currently only displaying one user. Does anyone know what modifications need to be made to make it list all users.

Private Sub cmd_Show_Users_Click()
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
Dim strSQL As String
While Not rs.EOF
'Debug.Print rs.Fields(0), rs.Fields(1), rs.Fields(2), rs.Fields(3)
strSQL = strSQL & rs.Fields(0) & "," & rs.Fields(1) & "," & rs.Fields(2) & "," & rs.Fields(3) & ";"
rs.MoveNext
Wend
MsgBox strSQL, , "List of Users"
Exit Sub
End Sub
 
Thanks David.

I currently use a similar tool (LDBViewer) but had hoped for a simple 'built-in' function.

I believe I am half way there. The code is based upon Microsoft's ShowUserRosterMultipleUsers module that lists current users in the imediate window. I now need to know how this code can be manipulated to display the results in a msg box.
 

Users who are viewing this thread

Back
Top Bottom