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?!
Thanks
Liam
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