determine who is logged onto a database

G

Guest

Hello, I have a main form and want to show who is currently loged into the
database on this form. I have found some Module code on microsoft help but I
dont know how to get it to show on my form? Is there some easy way to get
this to work? Thanks!!

Sub ShowUserRosterMultipleUsers() Dim cn As New ADODB.Connection Dim rs As
New ADODB.Recordset Dim i, j As Long 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
Sub


5 .Save the module as ShowUsers.
6. Press CTRL+G to open the Immediate Window.
7. Type the following line in the Immediate window, and then press ENTER:
ShowUserRosterMultipleUsers
Note that the Immediate window returns a list of users who are logged onto
the database.
 
G

Guest

You could try coding iut likes this (with line breaks):

Sub ShowUserRosterMultipleUsers()

Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim i, j As Long

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
Loop

End Sub

HTH

Philip
 
D

Douglas J. Steele

Yes, put it in a module (not a class module), and then continue with step 5
below.

All that module does, though, is write to the Immediate window (Ctrl-G).
You'll want to get it onto a form. What version of Access are you using?
 
G

Guest

You would put it in a code module as a Function.

Then to use it on a form, in the Event Builder you choose 'Build Event' and
from the event handler you call your function.

Alternatively, you can use it in the events of the form...

HTH

Philip
 
G

Guest

In new to this so im sorry I should have posted in new users! I made a new
module called ShowUsers now what? Im using access 2000 at work and 2003 to do
the touch ups at home...
 

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