How to Move to last item in listbox?

  • Thread starter Thread starter bhammer
  • Start date Start date
B

bhammer

Code to hightlight the last row in a listbox in two conditions:

1. When the form containing the listbox opened,
2. When the form containing the listbox is Activated.

-Brad
 
bhammer said:
Code to hightlight the last row in a listbox in two conditions:

1. When the form containing the listbox opened,
2. When the form containing the listbox is Activated.

-Brad

I got it.

Me.MyListbox.SetFocus
SendKeys "^{END}"

See Access Help for SendKeys. The carrot is Ctrl. Pushing Ctrl+End on the
keyboard puts you to the end of the list. Handy to know.
-Brad
 
bhammer said:
I got it.

Me.MyListbox.SetFocus
SendKeys "^{END}"

See Access Help for SendKeys. The carrot is Ctrl. Pushing Ctrl+End on the
keyboard puts you to the end of the list. Handy to know.
-Brad

Sendkeys is notoriously unreliable and not recommended for use in production
apps. A better method would be to use the listbox's Value and ItemData
properties, like this:

With Me.MyListbox
.Value = .ItemData(.ListCount - 1)
End with
 
Back
Top