select values in combo with cursor (1 Viewer)

BadScript

Registered User.
Local time
Today, 01:51
Joined
Oct 30, 2007
Messages
73
Hi all..
I have a form with 3 combo's and so far it works like a charm however I'd like to change 2 things. I'd like to make the selection using my cursor keys.

Second I'd like to turn off the autofill on my last combo. This combo only has 4 values which are : III, II, I, N .. Whenever I type an I it autofills the rest of my combo resulting in the value III, I'd like to turn the autofill option off..

Does anyone know how to do this?
 

MStef

Registered User.
Local time
Today, 09:51
Joined
Oct 28, 2004
Messages
2,251
For second; AUTO EXPAND properties, NO
 

BadScript

Registered User.
Local time
Today, 01:51
Joined
Oct 30, 2007
Messages
73
Thanks ! :D
 

missinglinq

AWF VIP
Local time
Today, 04:51
Joined
Jun 20, 2003
Messages
6,423
If you mean that you want to use your Up and Down Arrows to navigate thru the combobox withput having to use the cursor to drop the box down first, this code will allow that:

Code:
Private Sub YourComboBox_GotFocus()
  YourComboBox.Dropdown
End Sub
 

BadScript

Registered User.
Local time
Today, 01:51
Joined
Oct 30, 2007
Messages
73
In the example above the combos expand by default. I would like my combo to expand by using the down cursor key or just select values by using the cursor keys without expanding the combo. Does anyone know if this is possible?
 
Last edited:

missinglinq

AWF VIP
Local time
Today, 04:51
Joined
Jun 20, 2003
Messages
6,423
To keep it from dropping down when the combobox gets focus, delete this code:
Code:
Private Sub YourComboBox_GotFocus()
  YourComboBox.Dropdown
End Sub

To step thru the box using the Up and Down Arrows, without dropping the box down, use this code:
Code:
Private Sub YourComboBox_KeyDown(KeyCode As Integer, Shift As Integer)
  
  Select Case KeyCode
    Case vbKeyDown
      If YourComboBox.ListIndex <> YourComboBox.ListCount - 1 Then
        YourComboBox.ListIndex = YourComboBox.ListIndex + 1
      Else
        YourComboBox.ListIndex = 0
      End If
   Case vbKeyUp
      If YourComboBox.ListIndex <> 0 Then
        YourComboBox.ListIndex = YourComboBox.ListIndex - 1
      Else
        YourComboBox.ListIndex = YourComboBox.ListCount - 1
      End If
End Select

End Sub
In order to keep focus from leaving the combobox when you get to the beginning or the end of the selections, I have it "wrapping." If you get to the last selection and hit the Down Arrow again, it wraps back to the first selection ; if you're on the first selection and hit the Up Arrow it wraps around to the last selection.
 

Users who are viewing this thread

Top Bottom