Increment/Decrement ComboBox Index
Posted on 2006-06-22
I have a combobox to which I want to be able to increment or decrement the index by clicking a button.
The following is the code I have come up with so far, however, it is not performing the action as expected.
Dim NewIndex As Long
NewIndex = Me.CustomerIDCombo.ListIndex + 1
Me.CustomerIDCombo = Me.CustomerIDCombo.ItemData(NewIndex)
My first message box diplays the current combobox index. The second one shows that the variable NewIndex is set to the listindex plus 1. The third shows that the index did not change from the first message box.
I have put in numbers such as "Me.CustomerIDCombo = Me.CustomerIDCombo.ItemData(54)" and the index does change appropriately to the 54th row in the combobox.
It appears to me that the statement "Me.CustomerIDCombo = Me.CustomerIDCombo.ItemData(NewIndex)" is not able to accept the variable NewIndex. It has been defined as Long....
Any ideas or OTHER ideas would be greatly appreciated.