How to clear listbox selection

  • Thread starter Thread starter Rob Rutherford
  • Start date Start date
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.
 
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
 
Back
Top