Hello everyone.

I am building a small database that will hold information about volunteers and their talents. I have created a search form, in which the user can enter a keyword and it will search the tables for any match. Currently I am using a criteria of: Like "" & forms!SearchForm!Keywordtxt & "". It all works great... my only issue is that when I type "Ch" in the keyword box instead of just getting words that start with "Ch" like China, chair, chocolate and such i get any word that has CH... like Chair, computer tech, Techno....etc. How can I correct this so when I type "Ch" in the field the query will only give me results of the beginning of the word?

Any help in this matter will be greatly appreciated. I have not been able to find any answers on this. :(

Recommended Answers

All 4 Replies

It would be good if you post the actual code you use. One thing to look at: how are you positioning your wildcard characters in your search?

In a form I have created an unbound text box. Then in the sql query I am putting this under the criteria:

Like "" & [Forms]![SearchForm]![Keyword] & ""

When I type Ch on the search box it will bring up all the results that have ch within the words, instead of just giving me the results that start with ch.

Is there a way I can only display results that match by the beggining of the word. For example, If I want to search for all the volunteers that have a last name starting with S, i would type S in the search box, but instead of just giving me the results "Smith", "Simpson"...etc it gives me: "Smith", "Simpson", "Flowers"...and everything else that has an S somewhere in the word... : /

I don't have a copy of Access2010 handy, but there must be somewhere buried elsewhere that wraps your criterion with wildcard characters. Otherwise, it would only return rows that exactly match your Keyword field.

Try this, and see if it either helps or errors out:

Like [Forms]![SearchForm]![Keyword] & "*"

Note that there is now a wildcard character (the asterisk) concatenated with your keyword.

If it doesn't work, capture the error number. It would also help if you posted the full SQL statement you're using and say where it is that it's specified (like the Form Recordsource property?). Also, if you have any code such as "on keypress" or whatever, that occurs to change the Filter or forces a Refresh event.

Yes, I tried this but it still returns any results... not just what matches in the beginning of the word... I am still battling with this... see if I can get it to work at some point.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.