ADO: Connecting to backend (1 Viewer)

cricketbird

Registered User.
Local time
Today, 15:44
Joined
Jun 17, 2013
Messages
108
I have the handy Allen Browne function ShowUserRosterMultipleUsers installed in the frontend and backend of my database. When run, it tells you the computer names of the logged in users for that db.

Is there a way to run this on the backend FROM the frontend? I.e. see who is connected to the backend while looking at the frontend?

I assumed I would change the Set cn = CurrentProject.Connection to another string.
I tried debug.print CurrentProject.Connection within the backend, and then pasted the resulting string into the cn = statement on the frontend, but got a type mismatch error.


Thank you!


Code:
Public Function ShowUserRosterMultipleUsers()
    Dim cn As New ADODB.Connection
    Dim rs As New ADODB.Recordset


    Set cn = CurrentProject.Connection


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


End Function
 

June7

AWF VIP
Local time
Today, 11:44
Joined
Mar 9, 2014
Messages
5,473
What I do is have a Users table and when user opens their frontend, User record is updated with date/time. When they close frontend, the field is updated to Null.

Never seen that Allen Browne function. I will have to experiment.
 
Last edited:

cricketbird

Registered User.
Local time
Today, 15:44
Joined
Jun 17, 2013
Messages
108
What I do is have a Users table and when user opens their frontend, User record is updated with date/time. When they close frontend, the field is updated to Null.

Never seen that Allen Browne function. I will have to experiment.
Oooh - I like that way. I will experiment.
 

June7

AWF VIP
Local time
Today, 11:44
Joined
Mar 9, 2014
Messages
5,473
Allen's function was written for JET and mdb file. This worked for me:

cn.Provider = "Microsoft.ACE.OLEDB.12.0"
cn.Open "Data Source=C:\Users\Administrator\June\DOT\Airports\AirportsAdmin.accdb"

However, whether for accdb or mdb, code always returns connected as True, even when I know database is not being used.
Not sure this is correct function for what you want. Look at UserCount(). Never mind, seems to output same data.
 
Last edited:

Pat Hartman

Super Moderator
Staff member
Local time
Today, 15:44
Joined
Feb 19, 2002
Messages
43,280
I haven't used the code you are referring to but I have several versions of a stand alone database that probably uses similar code. It always includes the fe that is running the code so there is always at least one fe connected.
 

Users who are viewing this thread

Top Bottom