Adding to a list box with VBA

  • Thread starter Thread starter Stewart
  • Start date Start date
S

Stewart

So far I have a form which opens a report. If you have selected any input
(besides Null) for a combo box, I want it to show up on the report in a list
box. This should be very simple, but I cannot get the code to work. So far I
have:

If cboTrailNumber Is Not Null Then
Reports![rptSSa]![lstFiltered].AddItem ("Trail Number")
End If

In my button click procedure on my form. Any help would be greatly
appreciated.
 
Access Listboxes do not support the AddItem method.

Instead, try Reports!rptSSA!lstFIltered.Rowsource =
Reports!rptSSA!lstFIltered.Rowsource & [Trail Number] & ";"


Chris Nebinger
 
Chris:

That's not necessarily true. In Access 2002 and 2003, list boxes DO support
the .AddItem method, in previous versions, you had to use either a
query/table or a delimited string (value list) as the row source for a list
box, but since 2002, you can use Add Item.
--
Steve Arbaugh
ACG Soft
http://ourworld.compuserve.com/homepages/attac-cg

Chris Nebinger said:
Access Listboxes do not support the AddItem method.

Instead, try Reports!rptSSA!lstFIltered.Rowsource =
Reports!rptSSA!lstFIltered.Rowsource & [Trail Number] & ";"


Chris Nebinger

-----Original Message-----
So far I have a form which opens a report. If you have selected any input
(besides Null) for a combo box, I want it to show up on the report in a list
box. This should be very simple, but I cannot get the code to work. So far I
have:

If cboTrailNumber Is Not Null Then
Reports![rptSSa]![lstFiltered].AddItem ("Trail Number")
End If

In my button click procedure on my form. Any help would be greatly
appreciated.



.
 
Back
Top