Both combos have On Key Down events set, so the user can easily go trough the combo values.
Combo Client has "After Update" and "On Key Down" event set, and it works fine.
I used After Update event to take care manually (via code) the items that are not in the list.
On combo Country, however, there was no need for that and I've used "On Not in List" event instead. And that was working fine until I've added the "On Key Down" event.
Now as soon as I press the down cursor, it activates "Not on List" event and it gives me the message that the item is not on the list, although it obviously is.
After I press OK button, I get additional error "Run-time error 7777: You've used the Listindex property incorrectly."
When I go to debug, the next line is higlihted:
"Me.cmbCountry.ListIndex = Me.cmbCountry.ListIndex + 1"
Here is the full code of the KeyDown event:
Expand|Select|Wrap|Line Numbers
- Private Sub cmbCountry_KeyDown(KeyCode As Integer, Shift As Integer)
- Select Case KeyCode
- Case vbKeyDown
- KeyCode = 0
- If Me.cmbCountry.ListIndex <> Me.cmbCountry.ListCount - 1 Then
- Me.cmbCountry.ListIndex = Me.cmbCountry.ListIndex + 1
- End If
- Case vbKeyUp
- KeyCode = 0
- If Me.cmbCountry.ListIndex > 0 Then
- Me.cmbCountry.ListIndex = Me.cmbCountry.ListIndex - 1
- Else
- Me.cmbCountry.ListIndex = 0
- End If
- End Select
- End Sub