0

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. :(

2
Contributors
4
Replies
6
Views
4 Years
Discussion Span
Last Post by Geli19
0

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?

0

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... : /

0

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.

Edited by BitBlt

0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.