Clearing list boxes

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

Guest

I am wondering if it's possible to clear the contents of a list box. I want
to clear contents on the 'on click' command of another combo box on the same
form. Any suggestions?
 
What do you mean by "clear": empty it, or unselect any values that have been
selected?

To empty it, simply set its row source to an empty string.

To unselect selected values, you can use something like

Dim intLoop As Integer

For intLoop = 0 To Me!MyListBox.ListCount - 1
Me!MyListBox.Selected(intLoop) = False
Next intLoop
 
I am looking to empty the list box whose row source is a query. For this
reason I am unable to set the list box's row source to an empty string. Is it
possible to empty the box another way? Thanks for your help!
 
If you've got a list box that derives its data from a query, then whatever
the query gives you is what should be in that list box. If you don't want
anything in the list box, then you no longer want the query to be its row
source.

There should be nothing stopping you from changing the row source in VBA
code. It's something like:

Me!MyListBox.RowSource = ""

(replace MyListBox with whatever your listbox is called)
 

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