Current Users connected to the Database

Godber

New Member
Joined
Nov 27, 2013
Messages
30
Hi,

I have a multi-user database, as an internal function that only i have access to i would like to see who is connected to the database, i do currently have a form and code being used which successfully shows me all the computer names connected.

The code then populates a list box, the colomn headers i have are; "Computer;User;Connected?;Suspect?;ID"

but on the ID section i would like the code to return the username of the computer connected, however my code below returns my username for every entry.

Could someone please help?!

Code:
Private Function GenerateUserList()

Const conUsers = "{947bb102-5d43-11d1-bdbf-00c04fb92675}"
  
Dim cnn As ADODB.Connection, fld As ADODB.Field, strUser As String
Dim rst As ADODB.Recordset, intUser As Integer, varValue As Variant
  
Set cnn = CurrentProject.Connection
Set rst = cnn.OpenSchema(Schema:=adSchemaProviderSpecific, SchemaID:=conUsers)
  
strUser = "Computer;User;Connected?;Suspect?;ID"
 
With rst   
  Do Until .EOF
    intUser = intUser + 1
      For Each fld In .Fields
        varValue = fld.Value
          If InStr(varValue, vbNullChar) > 0 Then
            varValue = Left(varValue, InStr(varValue, vbNullChar) - 1)
          End If
          strUser = strUser & ";" & varValue
                Next
      strUser = strUser & ";" & Environ("UserName")
        .MoveNext
  Loop
End With
Me!txtTotalNumOfUsers = intUser       
 


Me!lstUsers.ColumnCount = 5
Me!lstUsers.RowSourceType = "Value List"
Me!lstUsers.ColumnHeads = True
  lstUsers.RowSource = strUser     
  


Set fld = Nothing
Set rst = Nothing
Set cnn = Nothing


End Function

Thanks

Liam
 

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top