If you can select multiple items in the list, which one are we supposed to use to select the "next item"?
If the record you are viewing is an old record, and you go to a new record, which item do you want to highlight as the "default" for the new record?
How are you navigating to the "next record"?
Are you using the standard navigation buttons, or some custom record controls?
If you are using the standard navigation buttons, I would recommend using the forms BeforeUpdate event to determine which item is selected in the listbox. You will need to:
1. create a private variable and declare it in the forms general declarations section.
2. Then, in the Forms BeforeUpdate event, call the attached subroutine (FirstSelectedListItem) to determine the first selected item in your listbox
3. Then, in the Forms Current event you should test to determine whether you are on a new record. If so, unselect all the selected items in the list (ClearListSelections), increment your variable, and select that item.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
|
Public Function FirstSelectedListItem(lst As ListBox) As Long
Dim varItem As Variant
For Each varItem In lst.ItemsSelected
FirstSelectedListItem = varItem
Exit Function
Next
End Function
Public Sub ClearListSelections(lst As ListBox)
Dim intLoop As Integer
For intLoop = 0 + Abs(lst.ColumnHeads) To lst.ListCount - 1 + Abs(lst.ColumnHeads)
lst.Selected(intLoop) = False
Next
End Sub
|