Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Count of users

Status
Not open for further replies.

solo7

Technical User
Mar 14, 2001
243
NO
Is there a way to count the number of users who are logged into a Db ??

Steady ... [thumbsup2]
 
There are 3 ways I can think of:
1: Have each user create a record in a logging table when they enter the database and remove it when they leave. Problem is if they leave in a way you have not planned for.
2: Read the ldb file, count the length of the text inside it & divide by the length when there is only 1 person in it (I used to know this number, can't think of it off hand tho!)
3: I once used some code from the M$ website I think that read the ldb file and counted the users and worked out who they were. I'm not sure how I found it, but you could try the knowledge base.

I'm sure there's an easier way than these!

Ben ----------------------------------
Ben O'Hara
bo104@westyorkshire.pnn.police.uk
----------------------------------
 
Put this function in the standard module and put the global up in the declarations area of the module.

'-- A LINK to check out that explains the function

Option Explicit
Global Const JET_SCHEMA_USERROSTER = _
"{947bb102-5d43-11d1-bdbf-00c04fb92675}"

Function ADOUserRoster()
Dim cnn As New ADODB.Connection
Dim rst As ADODB.Recordset

' Open the connection
' cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
' "Data Source=.\NorthWind.mdb;"

cnn.Open CurrentProject.Connection

' Open the user roster schema rowset
Set rst = cnn.OpenSchema(adSchemaProviderSpecific, , _
JET_SCHEMA_USERROSTER)

' Print the results to the debug window
' to check who is logged on.
Debug.Print rst.GetString

Dim cnt As Integer, indx As Integer
cnt = 0
rst.MoveFirst
For indx = 0 To 2000
If Not rst.EOF Then
cnt = cnt + 1
Else
Exit For
End If
rst.MoveNext
Next '- end for
Debug.Print "count of connections = "; cnt

cnn.Close

End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top