Clear a List Box

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

Guest

Your help will greatly be appreciated.

Have a query based on 4 drop down combo boxes in which the results are
displayed in a list box.
The user clicks a clear button to remove all combo box selections.
I want the list box to clear also. I tried several things but none of them
works
me.listbox = Null
me.listbox = " "

Also, I have used this : me.listbox.rowsource = ""

However, when the form loads/open I get a error message stating that it does
not recognize the rowsource "".

Thanks
 
Your help will greatly be appreciated.

Have a query based on 4 drop down combo boxes in which the results are
displayed in a list box.
The user clicks a clear button to remove all combo box selections.
I want the list box to clear also. I tried several things but none of them
works
me.listbox = Null
me.listbox = " "

Also, I have used this : me.listbox.rowsource = ""

However, when the form loads/open I get a error message stating that it does
not recognize the rowsource "".

Thanks

Code the Clear button click event:

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

Change ListBoxName to the actual name of your list box,
 
Thank you Fred.

I changed the listbox to the listbox actual name, howevery unfortunately it
does not work.
Your continued help will greatly be appreciated.
 
Hi Gwen

Do the following

Dim i As Long
For i = 0 To Me.ListBoxName.ListCount - 1
Me.ListBoxName.Selected(i) = False
Next i

Change 'ListBoxName' to the name of your listbox.

This will cycle through any selected items in your listbox.

M
 
Use the loop like Someone posted, but use the RemoveItem method instead - no
fast way to clear a listbox.
 

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

Back
Top