List box doesn't clear on requery

  • Thread starter Thread starter Simon Barton
  • Start date Start date
S

Simon Barton

Guest
I'm getting strange behaviour in a multi-select list box in Access 2000. I have VB code that can change the query underlying a multi-select list box. But re-querying the list box does not clear the selections (as Help says it should).

Worse than that, if there are fewer rows in the list box after the requery than before - say it goes from 10 lines to six - and prevously say lines seven to 10 were highlighted, the box continues to show rows 7 to 10 as highlighted i.e. beyond the data in the box... ghost selections in other words that you can't click on. Clicking elsewhere in the box resets everything but it looks messy

There seems to be no other way to clear the box other than requerying it or a VB loop to set each selected item to false but that doesn't work as it doesn't clear the ghost ones as they don't exist!!!

Is this just a bug or has anyone got any bright ideas? Help would be much appreciated
 
Clear the selection before requerying?

I haven't tried this but it might work.

On the event that will requery the list box, run code to clear all selection before the requery.

I can't remember the code exactly but it goes something like this:

Code:
'Remove selection before resetting rowSource
    For i = 0 To Me.lst_box.ListCount
        Me.lst_box.Selected(i) = False
    Next i

   'Then reset RowSource or Requery
 

Users who are viewing this thread

Back
Top Bottom