0
votes

I have a combo box with a list of customers which I am filtering as the user types. When the form loads there is a preset value in the combo box, however when I backspace the combo box doesn't update the value (it keeps the original customer). The value will only become null once I click away from the combo box. Then I click back and it starts filtering as I type.

I tried setting the focus to another control and then coming back to the combo box on the AfterUpdate events but the code doesn't change the focus

Private Sub cboCustCode_AfterUpdate()

Me.txtCustName = DLookup("[CUST_NAME]", "[PLACE_HOLDER_CUST_LIST]", "[CUST_CODE] = '" & Me.cboCustCode & "'")

Me.txtCustName.SetFocus
Me.cboCustCode.SetFocus

End Sub

I want to be able to backspace in the combo box and then start typing and see the filtered results

1

1 Answers

0
votes

I fixed it by checking if the combo box text length is 0 and then setting the combo box value = null

Private Sub cboCustCode_Change()

Me.txtCustName = DLookup("[CUST_NAME]", "[PLACE_HOLDER_CUST_LIST]", "[CUST_CODE] = '" & Me.cboCustCode & "'")
If Len(Me.cboCustCode.Text) = 0 Then

Me.cboCustCode = Null
End If


End Sub