Multiple Keywords Search Criteria (1 Viewer)

ListO

Señor Member
Local time
Today, 22:12
Joined
Feb 2, 2000
Messages
162
I'm, trying to make a query work which searches for one or more keywords.

The form which calls the query has an input textbox. I have code which strips and parses this input and concatenates it into a string with asterisks, etc. If the input textbox contains

dog bark loud

the string ends up as

"*dog*" OR LIKE "*bark*" OR LIKE "*loud*"

I thought I could enter this into the criteria of the query as:

Like [forms]![formname].[searchstring]

But this pulls up nothing. I've experimented with a dozen variations of the above, including trying to get the searchstring into the text of the SQL statement, but I can't make it work.

Where have I gone wrong?
 

llkhoutx

Registered User.
Local time
Today, 16:12
Joined
Feb 26, 2001
Messages
4,018
Try

Like ""*" & [forms]![formname].[searchstring] & "*""""
 

ListO

Señor Member
Local time
Today, 22:12
Joined
Feb 2, 2000
Messages
162
Thanks, but...

It doesn't work. I get an error:
Data Type Mismatch in Criteria Expression.
Looks like too many quotes to me.

If I cull down the quotes until I don't get an error, the query returns nothing.

Seems the problem is in how to pass criteria via a string. How's it supposed to be done?
 

llkhoutx

Registered User.
Local time
Today, 16:12
Joined
Feb 26, 2001
Messages
4,018
Here's an example from code which I use:

StrSQL="SELECT tbTimeExpense.* From tbTimeExpense WHERE ((tbTimeExpense.fBilled=0) AND (tbTimeExpense.FileID = [Forms]![frmTimeExpenseRecords]![cboFileID]) And (tbTimeExpense.mDescription Like "*Deposition*") OR (tbTimeExpense.mDescription Like "*Trial*")) ORDER BY tbTimeExpense.dtEntry, tbTimeExpense.TimeExpenseID;"
 

Users who are viewing this thread

Top Bottom