I am trying to filter my listbox lstOutput
on the fly as the user types into my textbox txtInput
however none of the key events on my textbox fire until I click my listbox and then go back to my textbox.
Here is the code I am using
Private Sub txtInput_KeyPress(KeyAscii As Integer)
Dim strSQL As String
strSQL = "SELECT Patient.PatientID, Patient.FName, Patient.LName " & _
"FROM Patient " & _
"WHERE (((Patient.FName)=[Forms]![New Session]![txtInput]) OR ((Patient.LName)=[Forms]![New Session]![txtInput])) " & _
"ORDER BY Patient.[FName], Patient.[LName];"
Me.lstResults.RowSource = strSQL
Me.lstResults.Requery
End Sub
I have tried the KeyUp
, KeyDown
, Dirty
, Change
events as well but to avail. The only one that works is the AfterUpdate
event but I won't the results to filter as the user types and not after pressing enter.