Microsoft Access Tips and Tricks
Select Next or Previous Item in List Box
Sometimes when you have a list of items, you want to programmatically move the selection through the items in the list. You may want to move down the list (select the next item after the current selection) or move up the list (select the previous item). For example, you might have a list of dates, with spin buttons to select the next date or the previous date.
Here are two functions you can call, one to select the next item in the list box, one to select the previous item. Both functions support an optional argument that will let the selection "wrap around" if you attempt to scroll past the last item or before the first item in the list. Please note: these functions only work with list boxes that are not in multiselect mode. There doesn't seem to be much point in using functions like these in a multiselect context.
code: click in the frame, Select All, then Paste into your code editor
Versions: Access 95 to 2007
Categories: VBA, Utility Functions
Date: 30 July 2009