I have a combobox the shows customers in the following format: CustomerName -- CustomerPhone
I can search for any customer by typing in the combobox the first letters of his/her name.
How can I do the same with CustomerPhone?
I have a combobox the shows customers in the following format: CustomerName -- CustomerPhone
I can search for any customer by typing in the combobox the first letters of his/her name.
How can I do the same with CustomerPhone?
Put the search query in the txtBox_change event.
you can't wait the 2 seconds to finish typing?
Well off course I can wait for the 2 seconds, but if I can do it while typing, it would be much better.
While typing in a txtBox, the change event does not update the value of txtBox, it triggers the event but it uses the old value of the txtBox, the data is updated only after the txtBox has lost focus.
the change event can also reference the .text property which is what is actually displayed in the textbox at that time. Note the text property can only accessed whilst the control has the focus.While typing in a txtBox, the change event does not update the value of txtBox, it triggers the event but it uses the old value of the txtBox,
OP started talking about a combo, now seems to be talking about a textbox. For clarity which is it?
can search for any customer by typing in the combobox the first letters of his/her name.the typeahead function for a combo only works in the first displayed column. So the easy answer is to have a second combo.How can I do the same with CustomerPhone?
An alternative, not tested, is in the on change event if the first char is numeric, change the rowsource from 'SELECT ID, Name, Phone....' to SELECT ID Phone, Name....'.
Or perhaps the code changes the column widths from 0;2;2; to 0;0;2
No idea if either will work but you can try. don't forget to change back if first char is not numeric
If this is for a search form then use a textbox and in the change event have something like
me.filter="[fldName] like '" & me.txtSearch.text & "*' OR [fldPhone] like '" & me.txtSearch.text & "*'"
me.filteron=true
Dynamic Multi Search.zip
Here's an example that I have found very helpful. It uses a text box and displays search results on each keystroke.
I think it is not a practical solution to filter a combobox as I am typing inside it, because it will update the combobox value directly after I type the first character and it will not allow me to continue typing.
I managed to solve it this way.
I used another textbox to filter the combobox
Private Sub textbox_Change()
combobox.value = DLookup("CustomerInfo", "Customer", "CustomerInfo like'*" & textbox.Text & "*'")
End Sub
The .text property is what I was looking for.
Thank you all for your replies
Nice example, unfortunately it uses a listbox and not a comboboxDynamic Multi Search.zip
Here's an example that I have found very helpful. It uses a text box and displays search results on each keystroke.
I try not to use them as bound controls because it's too easy mess up data when they're bound. All a user has to do is play with the list and create nonsense records. As data inputs, they're best left as unbound and use code to update, or use them strictly as controls for providing criteria or filtering values, which is what I mainly use them for.I think it is not a practical solution to filter a combobox as I am typing inside it, because it will update the combobox value directly after I type the first character and it will not allow me to continue typing.
The more we hear silence, the more we begin to think about our value in this universe.
Paraphrase of Professor Brian Cox.
Well, the rowsource SQL string for the list box could be used for a combo box rowsource as well.Nice example, unfortunately it uses a listbox and not a combobox
Agree with Micron that combo boxes used to enter search criteria should not be bound. That's a sure way to inadvertently contaminate existing data.