Howto Clear unbound Listbox Items

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.
 
F

fredg

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 = ""
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top