Combo box multiple column search help (1 Viewer)

bumbolicious

New member
Local time
Today, 10:38
Joined
May 8, 2019
Messages
3
Hello all,


I've got a Combo Box that I want to type any value from the columns called NAME and SURNAME that are in the table called CONTACTS and get the results without having to create separate Combo Boxes for NAME and SURNAME.


How can I do that? I've been searching the internet with no avail though.


Thank you in advance!
 

theDBguy

I’m here to help
Staff member
Local time
Today, 10:38
Joined
Oct 29, 2018
Messages
21,474
Hi. Welcome to the forum. When you say "results," are you referring to the records on the form or just the combobox?
 

bumbolicious

New member
Local time
Today, 10:38
Joined
May 8, 2019
Messages
3
Hello there!

Thank you very much for the welcome!


Well, my bad, with "results" I meant the records.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 10:38
Joined
Oct 29, 2018
Messages
21,474
Hello there!

Thank you very much for the welcome!


Well, my bad, with "results" I meant the records.
So, if this means you're using the combo to filter the form, then you really don't need to use a combo. You could use a textbox and enter either names in it. In the AfterUpdate event, or whichever event you're using, just include both fields in your search criteria.
 

bumbolicious

New member
Local time
Today, 10:38
Joined
May 8, 2019
Messages
3
Well, I'd like to do it with combo box if there's a way of course.:p
 

sxschech

Registered User.
Local time
Today, 10:38
Joined
Mar 2, 2010
Messages
793
Search the forum for Find as You Type or FAYT, a function that allows you to type letters in the combo box so if you know the last name you can begin typing the letters for that and it will find it as well as if you entered the letters for the first name.
 

Bullschmidt

Freelance DB Developer
Local time
Today, 12:38
Joined
May 9, 2019
Messages
40
How about something like this:

Assuming that you already have the combo box working the way you want (perhaps using UNION and/or DISTINCT etc.) then for the SQL to produce the proper records...
Code:
SELECT * FROM Contacts WHERE (Contacts.Name = Forms!MyForm!MyCombo) OR (Contacts.Surname = Forms!MyForm!MyCombo)
 
Last edited:

Micron

AWF VIP
Local time
Today, 13:38
Joined
Oct 20, 2018
Messages
3,478
If combo isn't bound, you can't type in it to search without code. Even then, 2 table fields are involved, so which one would you search based on "find as you type"?

If combo IS bound (which wouldn't make sense if it's to be used as a search tool), again, which field would you search on? It could only be the bound field. It makes no sense to allow last name search on a first name field, and 2 field search is the goal.

Regardless if combo or textbox, one isn't going to work.
 

Users who are viewing this thread

Top Bottom