Access 2003 - programming arrow keys with combo box

On an Access form, I'd like the up/down arrow keys to be used to navigate the values in a combobox, similar to how a listbox behaves. So, for example, if there are five values starting with "M", the user could enter "M" and then press the down arrow key to get to the other entries. Since it's a combo box, the user could also just continue to enter text.

I assume I need to program the keypress event to do this, but I'm not skilled enough in VBA. Can someone help

Thanks.



Answer this question

Access 2003 - programming arrow keys with combo box

  • Shane Stevens

    Thank you. Thank you. Thank you. You have made my life so much easier.
  • Morri1234

    Thanks very much. That did it.
  • ciberch

    Hello, heres some code that might get you started. Might not be 100% what your looking for but it's a start.

    Dim iSelectedIndex As Integer

    Private Sub Combo0_KeyDown(KeyCode As Integer, Shift As Integer)
    On Error Resume Next

    iSelectedIndex = Me.Combo0.ListIndex

    If KeyCode = vbKeyUp Then
    If iSelectedIndex > 0 Then
    iSelectedIndex = iSelectedIndex - 1
    Me.Combo0.Text = Me.Combo0.Column(0, iSelectedIndex)
    End If

    ElseIf KeyCode = vbKeyDown Then
    If iSelectedIndex < Me.Combo0.ListCount Then
    iSelectedIndex = iSelectedIndex + 1
    Me.Combo0.Text = Me.Combo0.Column(0, iSelectedIndex)
    End If

    End If

    End Sub



  • Access 2003 - programming arrow keys with combo box