Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search for text string in a query field 1

Status
Not open for further replies.

KamikazeMoth

Technical User
Dec 14, 2003
1
AU
I want to search a text field in a query, for a certain keyword.

EG : The brown dog sat on the cat (search : brown)

All I can come up with is the LIKE operator, but I have to put in the whole text string, which I don't know and isn't always the same.

Any ideas (am using Access2000)

cheers
 
Add a column to the query and put this in it. Since I don't know the name of your text field, I will just use a field called - TextFieldName.

MyWord: InStr([TextFieldName],"brown")

and in the criteria for that column put in:

>0

The InStr function will look for an occurance of the word in the field. If it finds the word, it will return the start position of the word. If it doesn't find the word in the text string, then it will return a 0 (zero).

So if the returned value is greater than 0 (zero), then the text string contains the word.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top