listbox madness

  • Thread starter Thread starter djc
  • Start date Start date
D

djc

For Each itm In Me.lstChosen.ItemsSelected
Me.lstChosen.RemoveItem (itm)
Next itm

the above code does not work. I want to remove all selected items from a
list box. It's source is a Value List. The above makes perfect sense to me
but I discovered that once the RemoveItem method is called ALL items are no
longer selected so the other items that were selected and supposed to be
removed at the time the call is made to the RemoveItems method are not
removed.

that sucks.

I can think of a least one round about way of getting around this but I want
to see if anyone else has something (hopefully better than mine.)

anyone?
 
There's more than one thing wrong with this. Copy the selected items into a
variable, then remove those, one by one, from the value list. But, if you
are removing items, you need to use the Count property, and remove them from
the bottom up, else everything moves up when you delete, and you'll
potentially miss half the entries.

Larry Linson
Microsoft Access MVP
 
Back
Top