additem error

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to add an item to my listbox via VBA. Why am I getting an error
when I try to do the following code:

Me!lst_SAMPLEID.additem "anything"

I get runtime error 438.....Object doesn't support this method.
 
Chace said:
I am trying to add an item to my listbox via VBA. Why am I getting an error
when I try to do the following code:

Me!lst_SAMPLEID.additem "anything"

I get runtime error 438.....Object doesn't support this method.

AddItem method OK in AC2003, Not OK in Previous.

You can use this sub to add items to a listbox. Just pass in the name of the
Listbox and the item to ADD:

Private Sub ListAddItem(LB As ListBox, strItemToAdd As String)
If LB.RowSource = "" Then
LB.RowSource = IIf(LB.RowSource = "", strItemToAdd, "")
Else
LB.RowSource = LB.RowSource & ";" & strItemToAdd
End If
ListBox0.AddItem strItemToAdd
End Sub
 
Sorry,

The sub was to demonstrate using the same sub in both versions, For < AC2003,
the line:

ListBox0.AddItem strItemToAdd

should be commented out...
 
Thanks. I finally figured out it was a Access version issue on my own.
However, your workaround is much better than the one I created (i.e
manipulating a dummy table as the rowsource for the listbox). Your way is
much cleaner, thanks....I will use it.

--Chace
 
Back
Top