Criteria = Like "*this*" With Prompted Entry

T

Tecknomage

Sorry if this is answered elsewhere, but I couldn't figure out a search
phrase that gave me an answer.

The database has a field containing strings.

I want to create a query using> LIKE "*this*" <where "this" is a prompted
input from a user to do a sub-string search. Example, search the
string-field for the sub-string "bow".

Running the query would prompt the user to [Enter search string] and "this"
would become what they want to query.

I cannot figure out how to get the prompt to work.

(Comment: Lotus is much easier to use, especially something like this)
 
M

Michel Walsh

Hi,


If * is the wildcard (can be % too), try

LIKE "*" & [prompt to the user:] & "*"


as criteria.

Hoping it may help,
Vanderghast, Access MVP
 
C

Chris Burnette

For the most part, this is fairly simple, the only thing that is tricky are
the asterisks. If you simple put 'Like [Enter search string]' (without the
single quotes) in your query criteria, it will work. The only caveat is that
then the user has to enter the asterisks if he wants to do a wildcard search.


If the asterisks are really crucial, then you'll probably need to put your
query into VB and assign your "This" value to a text string. Then, you could
probably pull it off using something like:

'WHERE [MyTable].[MyField] Like [MyTable].["* & This & *"]'.

Hope that helps.

-Chris
 
T

Tecknomage

Michel Walsh said:
Hi,


If * is the wildcard (can be % too), try

No. The "*" in LIKE "*this*" = contains characters "this"

Example: LIKE "*cat*" would return records with the characters "cat" in the
field, it would return a record with "MajorWeponCatclaw" in the field.

LIKE "*" & [prompt to the user:] & "*"


as criteria.

Hoping it may help,
Vanderghast, Access MVP


Tecknomage said:
Sorry if this is answered elsewhere, but I couldn't figure out a search
phrase that gave me an answer.

The database has a field containing strings.

I want to create a query using> LIKE "*this*" <where "this" is a
prompted
input from a user to do a sub-string search. Example, search the
string-field for the sub-string "bow".

Running the query would prompt the user to [Enter search string] and
"this"
would become what they want to query.

I cannot figure out how to get the prompt to work.

(Comment: Lotus is much easier to use, especially something like this)
 
M

Michel Walsh

Hi,


with

LIKE "*" & [prompt to the user:] & "*"


if the end user type

cat


at the prompt, then a record with "MajorWeaponCatClaw" WILL be selected,
indeed. You have tried it? That is not what you want?



Vanderghast, Access MVP


Tecknomage said:
Michel Walsh said:
Hi,


If * is the wildcard (can be % too), try

No. The "*" in LIKE "*this*" = contains characters "this"

Example: LIKE "*cat*" would return records with the characters "cat" in
the
field, it would return a record with "MajorWeponCatclaw" in the field.

LIKE "*" & [prompt to the user:] & "*"


as criteria.

Hoping it may help,
Vanderghast, Access MVP


Tecknomage said:
Sorry if this is answered elsewhere, but I couldn't figure out a search
phrase that gave me an answer.

The database has a field containing strings.

I want to create a query using> LIKE "*this*" <where "this" is a
prompted
input from a user to do a sub-string search. Example, search the
string-field for the sub-string "bow".

Running the query would prompt the user to [Enter search string] and
"this"
would become what they want to query.

I cannot figure out how to get the prompt to work.

(Comment: Lotus is much easier to use, especially something like this)
 
T

Tom Ellison

Dear Teck:

Likely, you are wanting to select "words" delimited by spaces. Is that the
case?

How about:

WHERE " " & [YourColumnName] & " " LIKE "* " & [Enter search string: ] & "
*"

If you want to find ",this" you're going to have some work to do. Are there
delimiters other than space?

Tom Ellison


Tecknomage said:
Michel Walsh said:
Hi,


If * is the wildcard (can be % too), try

No. The "*" in LIKE "*this*" = contains characters "this"

Example: LIKE "*cat*" would return records with the characters "cat" in
the
field, it would return a record with "MajorWeponCatclaw" in the field.

LIKE "*" & [prompt to the user:] & "*"


as criteria.

Hoping it may help,
Vanderghast, Access MVP


Tecknomage said:
Sorry if this is answered elsewhere, but I couldn't figure out a search
phrase that gave me an answer.

The database has a field containing strings.

I want to create a query using> LIKE "*this*" <where "this" is a
prompted
input from a user to do a sub-string search. Example, search the
string-field for the sub-string "bow".

Running the query would prompt the user to [Enter search string] and
"this"
would become what they want to query.

I cannot figure out how to get the prompt to work.

(Comment: Lotus is much easier to use, especially something like this)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top