B
BillD
I have a combo box that I would like to use the arrow keys on my keyboard to
navigate through. The combo box is to select states. When I type in the first
letter I get for example Maine. I would like to be able to use my arrow keys
to move to another state for example Minnesota.
I was give a code to type in but I now get a run time error 424 whenever I
try to enter anything in the texbox or use the arrow on the text box.
The error code reads: Run Time Error '424'; Object Required.
When I click on the debug button I get the code which is below and the line
"If KeyCode = VbKeyDown and Combobox.ListIndex <> Combobox.ListCount - 1
Then" is highlighted in yellow. I did a copy paste so the below code is
exactly as it appears in my database.
Private Sub CoState_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyDown And ComboBox.ListIndex <> ComboBox.ListCount - 1 Then
ComboBox.ListIndex = ComboBox.ListIndex + 1
End If
If KeyCode = vbKeyUp And ComboBox.ListIndex <> -1 Then
ComboBox.ListIndex = ComboBox.ListIndex - 1
End If
End Sub
I am still learning Acess so if you could explain what I need to do in
simple terms I would appreciate it.
Thank you for your time and help
navigate through. The combo box is to select states. When I type in the first
letter I get for example Maine. I would like to be able to use my arrow keys
to move to another state for example Minnesota.
I was give a code to type in but I now get a run time error 424 whenever I
try to enter anything in the texbox or use the arrow on the text box.
The error code reads: Run Time Error '424'; Object Required.
When I click on the debug button I get the code which is below and the line
"If KeyCode = VbKeyDown and Combobox.ListIndex <> Combobox.ListCount - 1
Then" is highlighted in yellow. I did a copy paste so the below code is
exactly as it appears in my database.
Private Sub CoState_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyDown And ComboBox.ListIndex <> ComboBox.ListCount - 1 Then
ComboBox.ListIndex = ComboBox.ListIndex + 1
End If
If KeyCode = vbKeyUp And ComboBox.ListIndex <> -1 Then
ComboBox.ListIndex = ComboBox.ListIndex - 1
End If
End Sub
I am still learning Acess so if you could explain what I need to do in
simple terms I would appreciate it.
Thank you for your time and help