How to clear listbox selection

R

Rob Rutherford

Win XP, Access 2002. I'm trying to solve a problem with a single column listbox that displays selected values from a table whenever
its RowSource is changed in code. If I select an item so that it is highlighted, then invoke the code to change the RowSource, the
box is refilled with no item highlighted. However, if the RowSource is then changed back to what it was when I selected the item,
this same item is still highlighted. I'd like to stop this behaviour. Each time the box is repopulated I want nothing to appear
selected. Any advice would be appreciated.
 
D

Dirk Goldgar

Rob Rutherford said:
Win XP, Access 2002. I'm trying to solve a problem with a single
column listbox that displays selected values from a table whenever
its RowSource is changed in code. If I select an item so that it is
highlighted, then invoke the code to change the RowSource, the box is
refilled with no item highlighted. However, if the RowSource is then
changed back to what it was when I selected the item, this same item
is still highlighted. I'd like to stop this behaviour. Each time the
box is repopulated I want nothing to appear selected. Any advice
would be appreciated.

If this is not a multi-select list box, try setting the list box's value
to Null when you change its rouwsource; e.g.,

With Me.MyListbox
.Value = Null
.RowSource = <whatever>
End With
 

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