Reputation: 23
I have a combo box that shows a list of options as you type in it, however when I try to navigate through the list using the keyboard arrow keys, it selects the first option and removes the other options. The only way that I can choose other options is by using the mouse. I want the user to be able to navigate the options using keyboard arrow keys.
Here is my code for the combobox (cboSubject):
Private Sub cboSubject_Change()
Dim strFilter As String
strFilter = Me.cboSubject.Text
Me.cboSubject.RowSource = _
"SELECT tblSubjects.Subject, tblSubjects.Stage, tblSubjects.Semester, tblSubjects.SubjectID " & _
"FROM tblSubjects " & _
"WHERE (((tblSubjects.Stage) Like [screen].[ActiveForm].[cboStage] & '*') " & _
"AND ((tblSubjects.Subject) Like '*" & strFilter & "*')) " & _
"ORDER BY tblSubjects.Stage, tblSubjects.Semester, tblSubjects.SubjectID;"
Me.cboSubject.Dropdown
End Sub
Upvotes: 1
Views: 239
Reputation: 23
I managed to solve the issue by just changing the event from change to key press. The change event appears to be fired every time the text in the combo box changes. This includes when navigating through the list using the keyboard arrow keys. Once I used the keypress event, the problem is gone.
Upvotes: 1