.AddItem method not working



I need a method of populating a List Box using code. I am trying to create a
form where you can see who is logged into the application. I found some code
in Oreilly ACC Cookbook but it uses a method or member not found (.AddItem).
The code below is attached to a forms on_Open() property and contains a list
box named lboConnections with two columns named Compter Name, and User Name.

my referances are(VB for App, MS 9.0 OL, OLE Auto, and MS ActiveX Data Obj
2.1 Lib)

Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim strComputerName As String

Set cnn = CurrentProject.Connection
Set rst = cnn.OpenSchema(adSchemaProviderSpecific, , _
"{947bb102-5d43-11d1-bdbf-00c04fb92675}")
lboConnections.RowSource = vbNullString
lboConnections.AddItem "Computer Name;Login Name"

Do While Not rst.EOF
If rst("Connected") Then
strComputerName = rst("Computer_Name")
lboConnections.AddItem _
Left(strComputerName, _
InStr(strComputerName, vbNullChar) - 1) & _
";" & rst("Login_Name")
End If
rst.MoveNext
Loop
rst.Close
Set rst = Nothing
Set cnn = Nothing

I can sucessfully retreive the users via code, but I can't figure out how to
feed that to a form.

.



Relevant Pages

  • Re: ADO RecordCount -1
    ... Dim cnn As ADODB.Connection ... > Dim rst As ADODB.Recordset ... > Set cnn = New ADODB.Connection ...
    (microsoft.public.data.ado)
  • run-time error 3705
    ... When the user makes a selection from the combo box some vba code runs to ... Dim sqlString As String ... Dim rst As adodb.Recordset ... Set cnn = CurrentProject.Connection ...
    (microsoft.public.access.modulesdaovba)
  • Re: .AddItem method not working
    ... Do I place the sub ListAddItem in my forms module? ... >1 Dim cnn As ADODB.Connection ... >2 Dim rst As ADODB.Recordset ... >4 Set cnn = CurrentProject.Connection ...
    (microsoft.public.access.formscoding)
  • Re: Subform - which records are selected...
    ... Dim cnn As New ADODB.Connection ... Set cnn = Application.CurrentProject.Connection ... > transactions on Microsoft SQL Server. ... >> the selected records in one transaction? ...
    (microsoft.public.access.forms)
  • Re: Count number of Records Query always returns -1
    ... My total code is:- ... Dim MyVar As Boolean ... Set cnn = CurrentProject.Connection ... Others say that as long as you use a clientside cursor, it's OK, or use ...
    (microsoft.public.access.queries)