Refreshing List Box

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

Guest

Hi,
How can I "refresh" a list box of values? That is, after the "refresh"
button is clicked, I need the list box ListBox1 to do the following:
1 - requery (now using me!ListBox1.requery --> seems to work fine)
2 - no items in list box selected ( Me!ListBox1.Selected(-1) = True does not
work. It appears to be working wth Me!ListBox1 = -1, not sure why)
3 - and the listbox returns to the top of the list (don't know how to do
this yet)

I'm having trouble in particular with number 3 above: I can't return the
listbox to show line the top of the list. I also tried me.refresh, but
doesn't do the trick either.
I'm using MsAccess 2000. Any pointers would help. Thanks in advance.
 
One trick to unselect all of the records in a multiselect list box is to
reset its Row Source:

Me.MyListBox.RowSource = Me.MyListBox.RowSource

(This will not work with a single select list box)

For an extended multiselect list box, you also have the option of setting it
to Null to unselect all rows:

Me.MyListBox = Null

(This also works for a single select list box, but not for a simple
multiselect list box)

Another way of unselecting all of the rows is to loop through the
ItemsSelected collection:

Dim varItem As Variant

For Each varItem In Me.MyListBox.ItemsSelected
Me.MyListBox.Selected(varItem) = False
Next varItem


To go back to the top, select the first row, and then unselect it if you
don't want it selected:

Me.MyListBox.Selected(0) = True
Me.MyListBox.Selected(0) = False
 
Douglas, the
Me.MyListBox.Selected(0) = True
Me.MyListBox.Selected(0) = False
works great! I did change the row to 1 since there's header in listbox.
Thank you very much!
 
Back
Top