'------ start of code ------ Function fncSelectNextInListbox( _ lst As Access.ListBox, _ Optional bWrap As Boolean) _ As Long ' Select the next item in the list box passed as. ' If no item is selected, select the first one. ' If the optional argument is True, then the selection ' will wrap around from the last item in the list box to the ' first item. ' NOTE: THIS FUNCTION ONLY WORKS FOR NON-MULTISELECT LIST BOXES. ' Copright (c) 2009, DataGnostics LLC. ' You are free to use this code in your application, so long ' as the copyright notice remains unchanged. Dim lngMaxIndex As Long Dim lngFirstIndex As Long With lst If .ListCount <> 0 Then lngFirstIndex = Abs(.ColumnHeads) lngMaxIndex = .ListCount - lngFirstIndex - 1 If .ItemsSelected.Count = 0 Then .Value = .ItemData(lngFirstIndex) Else If .ListIndex >= lngMaxIndex Then ' We're at the end of the list box. If bWrap Then .Value = .ItemData(lngFirstIndex) End If Else .Value = .ItemData(.ListIndex + lngFirstIndex + 1) End If End If End If fncSelectNextInListbox = .ListIndex End With End Function Function fncSelectPreviousInListbox( _ lst As Access.ListBox, _ Optional bWrap As Boolean) _ As Long ' Select the previous item in the list box passed as . ' If no item is selected, select the first one. ' If the optional argument is True, then the selection ' will wrap around from the first item in the list box to the ' last item. ' NOTE: THIS FUNCTION ONLY WORKS FOR NON-MULTISELECT LIST BOXES. ' Copright (c) 2009, DataGnostics LLC. ' You are free to use this code in your application, so long ' as the copyright notice remains unchanged. Dim lngMaxIndex As Long Dim lngFirstIndex As Long With lst If .ListCount <> 0 Then lngMaxIndex = .ListCount - 1 lngFirstIndex = Abs(.ColumnHeads) If .ItemsSelected.Count = 0 Then .Value = .ItemData(lngMaxIndex) Else If (.ListIndex + lngFirstIndex) <= lngFirstIndex Then ' We're at the top of the list box. If bWrap Then .Value = .ItemData(lngMaxIndex) End If Else .Value = .ItemData(.ListIndex - 1 + lngFirstIndex) End If End If End If fncSelectPreviousInListbox = .ListIndex End With End Function '------ end of code ------