Solved

Auto scrolling in a list box

Posted on 2001-06-05
2
151 Views
Last Modified: 2012-06-27
I have a list box that stores a list of user names.  The form gives the option of viewing the names either by the NT Logon name (ie PHIGGINS) or by Last Name, First Name (ie Higgins, Peter).

I've got code that switches between them fine and the same user remains selected.  The problem I'm having is that the list box doesn't scroll to show the name, so the user can't see that it is selected.  For instance, if the first 20 names are shown in the list box and one is selected and then the display is changed, because the listbox is sorted, that name may be the 50th in the list, but the listbox still only shows the first 20 and the user has to scroll down to see the selected name.

Is there any way to make a listbox automatically scroll to show a selected entry?
0
Comment
Question by:peteyhiggins
2 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 50 total points
ID: 6156557
If you set the .TopIndex = .ListIndex for the list box then the selected row should be shown at the top of the list.
0
 
LVL 3

Expert Comment

by:nigelrowe
ID: 6156647
Yep, just put that code in the Click event of the list box
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

837 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question