Show users logged into the Access system

aman

Registered User.
Local time
Today, 13:02
Joined
Oct 16, 2008
Messages
1,251
Hi guys

In the following code, only rs.fields(0) value gets displays and all other values don't appear in the listbox.Its a single column listbox.

ANy idea why?

Code:
Private Sub Command0_Click()
ShowUserRosterMultipleUsers
End Sub
Sub ShowUserRosterMultipleUsers()
    Dim cn As New ADODB.Connection
    Dim cn2 As New ADODB.Connection
    Dim rs As New ADODB.Recordset
    Dim i, j As Long
    cn.Provider = "Microsoft.Jet.OLEDB.4.0"
    cn.Open "Data Source=J:\a.mdb"
   
    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
    
     Me.List1.AddItem rs.Fields(0) & " " & rs.Fields(1) & " " & rs.Fields(2) & " " & rs.Fields(3)
     rs.MoveNext
    Wend
End Sub
 
Perhaps put a watch on the rs object, do stepped execution, and make sure the other fields actually have a value. You really prefer numbered references as opposed to using the field names?
 
It is best to use the field name, code like this, then check the number of columns list box of 4.
Code:
Sub ShowUserRosterMultipleUsers()
    Dim cn As New ADODB.Connection
    Dim cn2 As New ADODB.Connection
    Dim rs As New ADODB.Recordset
    Dim i, j As Long
    cn.Provider = "Microsoft.Jet.OLEDB.4.0"
    cn.Open "Data Source=J:\a.mdb"
    Set rs = cn.OpenSchema(adSchemaProviderSpecific, , "{947bb102-5d43-11d1-bdbf-00c04fb92675}")
    Do Until rs.EOF
        Me.List1.AddItem rs!COMPUTER_NAME & " " & rs!LOGIN_NAME & " " _
                       & rs!CONNECTED & " " & rs!SUSPECT_STATE
        rs.MoveNext
    Loop
End Sub
 
Last edited:

Users who are viewing this thread

Back
Top Bottom