Question

So I have a form that has a listbox that shows like a ledger. My question is how can I make it display the last records (or have the scroll bar default to the bottom instead of the top), instead of the first few as the default.

Now I don't mean reversing the order from bottom to top instead of top to bottom (though that would be a cool thing to learn how to do), just simply having the bottom of the list (in terms of the scroll bar) shown and the default, so that it is always showing the last 10 or so records (based on the size that I made the list box).

So i think this is simple, but then again, I obviously do not know?!?!

Thanks!

Was it helpful?

Solution

In a suitable event, such as the current event:

 Me.ListX.Selected(Me.ListX.ListCount - 1) = True

OTHER TIPS

You could add some code to the form load event so that it will do this:

YourListBox.SetFocus
YourListBox.ListIndex = YourListBox.ListCount - 1
YourListBox.Selected(YourListBox.ListCount - 1) = False

It basically selects the last item in the list box so it will scroll down to it, and then unselects it.

I know this is later but maybe this will help someone in the future who comes upon this thread. This is the code I used to go to the last record then unselect the last record.

 YourListBox.SetFocus
 YourListBox.Selected(YourListBox.ListCount - 1) = True
 YourListBox.Selected(YourListBox.ListCount - 1) = False

How did you set the listbox items? Are they from a database? If yes, then you need to update the SQL statement with an "order by columnName".

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top