Re: Who Is Logged On?



There are no error messages, the form displays and the list box is empty.
There are no other indications of what is wrong. I changed the list box
property to "Value List" and changed the colon to a semi-colon. I changed
the reference to the list box to "Me.lstCurrentUsers.ControlSource =
strUsers" and recompiled. I put a break in the load subroutine and found
that function ReturnUsers returns only the name of the computer I am using,
but even that is NOT displayed in the list box, but it does show up in the
properties box as the Control Source property.

Any source of help would be appreciated.

EarlCPhillips
Ex-Mainframer Learning Access To Make
Local Food Bank More Efficient
Harvesters Community Food Network
--
Trying To Feed The Hungry


"Douglas J. Steele" wrote:

"cannot get it to work" doesn't mean much.

What happens when you try? Do you get an error? If so, what's the error? If
you don't get an error, what happens, and what do you expect to happen
instead?

One thing I question is the use of colon in:

ReturnUsers = rst(0) & ":" & ReturnUsers

AFAIK, you need semi-colon delimitation for list and combo boxes. As well,
have you set the RowSourceType property of lstCurrentUsers to Value List?

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"EarlCPhillips" <EarlCPhillips@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:4ED1F6FE-0F3E-49A0-AC7D-FB52DC3C449C@xxxxxxxxxxxxxxxx
From "Automatine Microsoft Access With VBA" by Susan Sales Harkins and
Mike
Gunderloy published by Que Publishing, 2005, ISBN 0-7897-3244-0, I took a
routine from page 250-1 which publishes a function which gives something
to
see who is connected to the database. I cannot get it to work for me.
The
code is as follows:
Public Const JET_SCHEMA_USERROSTER =
"{947bb102-5d43-11d1-bdbf-00c04fb92675}"
Public Function ReturnUsers() As String
On Error GoTo Err_ReturnUsers
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Set cnn = New ADODB.Connection
Set rst = New ADODB.Recordset
'open connection to database
Set cnn = CurrentProject.Connection
'open schema recordset to grab user metadata
Set rst = cnn.OpenSchema(adSchemaProviderSpecific, , _
JET_SCHEMA_USERROSTER)
'return current users
rst.MoveFirst
Do Until rst.EOF
ReturnUsers = rst(0) & ":" & ReturnUsers
rst.MoveNext
Loop

Exit_ReturnUsers:
rst.Close
Set rst = Nothing
cnn.Close
Set cnn = Nothing
Exit Function
Err_ReturnUsers:
MsgBox "Error " & Err.Number & ": " & Err.Description
Resume Exit_ReturnUsers
End Function

I built a form that contains a list box. The code to activate the form
is:
Private Sub Form_Load()
On Error GoTo Err_Form_Load
Dim strUsers As String
'populate listbox with current users
strUsers = ReturnUsers
lstCurrentUsers.ControlSource = strUsers
Exit_Form_Load:
Exit Sub
Err_Form_Load: 'handles any error condition
MsgBox "Error number: " & Err.Number & vbCr & Err.Description
Resume Exit_Form_Load
End Sub

What am I doing wrong? Any suggestions?

EarlCPhillips
Ex-Mainframer Learning Access to Make
Local Food Bank Feed Hungry More Efficiently
Harvesters Community Food Network
--
Trying To Feed The Hungry



.



Relevant Pages

  • Re: Who Is Logged On?
    ... Dim cnn As ADODB.Connection ... Set rst = New ADODB.Recordset ... Set cnn = CurrentProject.Connection ... Dim strUsers As String ...
    (microsoft.public.access.modulesdaovba)
  • Re: Who Is Logged On?
    ... How to determine who is logged on to a database by using Microsoft Jet ... Set rst = New ADODB.Recordset ... Set cnn = CurrentProject.Connection ... Dim strUsers As String ...
    (microsoft.public.access.modulesdaovba)
  • RE: Who Is Logged On?
    ... How to determine who is logged on to a database by using Microsoft Jet ... Set rst = New ADODB.Recordset ... Set cnn = CurrentProject.Connection ... Dim strUsers As String ...
    (microsoft.public.access.modulesdaovba)
  • RE: Who Is Logged On?
    ... How to determine who is logged on to a database by using Microsoft Jet ... Set rst = New ADODB.Recordset ... Set cnn = CurrentProject.Connection ... Dim strUsers As String ...
    (microsoft.public.access.modulesdaovba)
  • Re: Who Is Logged On?
    ... Feed The Hungry More Efficiently ... How to determine who is logged on to a database by using Microsoft Jet ... Set rst = New ADODB.Recordset ... Set cnn = CurrentProject.Connection ...
    (microsoft.public.access.modulesdaovba)