How to Move to last item in listbox?

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
 
B

bhammer

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
 
S

Stuart McCall

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top