VBA coding for User count

A

Alp

Hi Experts,

Is it possible to get a count of users without referencing to AxcitveX and
also to have a restriction when a certain number is reached?

Hope the question makes sense.

Thanks in advance,

Alp
 
A

Alp

Thanks Allen but it indicates that there is a requirement for reference to
MS AxtiveX Data Objects Library 2.1 or later.

Do I stand any chance in finding one that works under DAO reference?

Alp
 
P

Paul Overway

Here is a late binding example based on the KB article Allen referenced...no
reference required:

Sub ShowUserRosterMultipleUsers()
Dim cn As Variant 'New ADODB.Connection
Dim cn2 As Variant 'As New ADODB.Connection
Dim rs As Variant 'As New ADODB.Recordset
Dim i, j As Long

Set cn = CreateObject("ADODB.Connection")
' Set cn2 = CreateObject("ADODB.Connection")

cn.Provider = "Microsoft.Jet.OLEDB.4.0"
cn.Open "Data Source=" & CurrentDb.Name

' cn2.Open "Provider=Microsoft.Jet.OLEDB.4.0;" _
' & "Data Source=" & CurrentDb.Name

' The user roster is exposed as a provider-specific schema rowset
' in the Jet 4 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(-1, _
, "{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
Debug.Print rs.Fields(0), rs.Fields(1), _
rs.Fields(2), rs.Fields(3)
rs.MoveNext
Wend

End Sub

Note the count will be off by at least one (1), because you're creating a
connection in the code...plus whatever DAO instance you already have. The
original sample was off by two (2) because of the 2 connections it created.
 
A

Alp

Hi Paul,

Thanks, got the first part; counting the users.

Now I will have to find out how to disallow new connections when a certain
number is reached.

Alp
 
A

Alp

Hi Allen,

Thank you for the link. I had actually tried that AppUser earlier and
couldn't manage to get things out of it much. One thing was; it was not
refreshing itself and kept on showing users that had actually logged off.
Maybe something was wrong with my PC.

Anyway, the first phase seems to be done now I am trying to find a way to
disallow new users, say after 25 users in the DB.

Alp
 
T

Terry_Peters

Hello all,

I have used the code found in Q198755 and get the display in the Immediate
Window. My question is how can I get this same information into a table or
display in a query?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top