|
|

Navigating a Combo Box with the keyboard
If you are using a Combo Box to allow the user to select data, and there a quite a few records in the data, then you might wish to make it easier for the user to navigate through these records, especially if the only difference between some of the records is the last character. Whilst Access allows you to use the up and down cursor keys for this, you have to force the Combo Box to drop down, which will either require some coding, or else the use of the mouse. I don't like this method, as it takes up temporary space on the screen, and also the first use of the cursor key just moves onto the dropped down data. Below I show an alternative:
Private Sub cboCategoryID_KeyDown(KeyCode As Integer, Shift As Integer)
On Error GoTo E_Handle
Select Case KeyCode
Case vbKeyDown
KeyCode = 0
If Me!cboCategoryID.ListIndex <> Me!cboCategoryID.ListCount - 1 Then
Me!cboCategoryID.ListIndex = Me!cboCategoryID.ListIndex + 1
End If
Case vbKeyUp
KeyCode = 0
If Me!cboCategoryID.ListIndex <> 0 Then
Me!cboCategoryID.ListIndex = Me!cboCategoryID.ListIndex - 1
End If
End Select
sExit:
On Error Resume Next
Exit Sub
E_Handle:
MsgBox Err.Description, vbOKOnly + vbCritical, "Error: " & Err.Number
Resume sExit
End Sub |
Top
HOME |
NEW |
TABLES |
QUERIES |
FORMS |
REPORTS |
GENERAL |
API |
DOWNLOADS |
TUTORIAL |
RESOURCES
E-MAIL
Copyright & Disclaimer
|
| |