Howto Clear unbound Listbox Items

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

Guest

Hello,

I’ve come across an annoying problem. How to clear all Items in a Listbox
control?
The Listbox is unbound and has been filled programmatically. Of course I can
cycle through all items and use the removeitem method but it's not a very
efficient method. Any suggestions? Thank you.
 
Hello,

I¢ve come across an annoying problem. How to clear all Items in a Listbox
control?
The Listbox is unbound and has been filled programmatically. Of course I can
cycle through all items and use the removeitem method but it's not a very
efficient method. Any suggestions? Thank you.

I'm not sure what you mean by "clear all the Items".
Do you mean to unselect all the items in a multi-select list box that
have been selected?

Dim varItem As Variant
For Each varItem In ListBoxName.ItemsSelected
ListBoxName.Selected(varItem) = False
Next varItem

Do you mean clear the row source completely so the entire list box is
blank?

Me!ListBoxName.RowSource = ""
 
I'm not sure what you mean by "clear all the Items".
Do you mean to unselect all the items in a multi-select list box that
have been selected?

Dim varItem As Variant
For Each varItem In ListBoxName.ItemsSelected
ListBoxName.Selected(varItem) = False
Next varItem

Do you mean clear the row source completely so the entire list box is
blank?

Me!ListBoxName.RowSource = ""

So simple... yet I didn´t find it out :(
me.listboxname.rowsource="" does the trick nicely...thank you very much
 
Back
Top