Can I query using 2 *

T

Tall Mary

I have a Book Database with one field named Titles.
Is it possible to make a query using 2 partial names in the field name to
get all the matching items I want in one query?
For example, *Gone* (Gone Fishing, Gone with the Wind, Gone Crazy, etc) and
*Parenting*(for Modern Day Parenting, Good Parenting Skills, Parenting a
Teenager, etc), so I get all 6 Book Titles ?
I tried Like "*" Or [Enter Partial Title of Book] & "*" but it returns
the entire database's Book Titles. Help.
 
F

fredg

I have a Book Database with one field named Titles.
Is it possible to make a query using 2 partial names in the field name to
get all the matching items I want in one query?
For example, *Gone* (Gone Fishing, Gone with the Wind, Gone Crazy, etc) and
*Parenting*(for Modern Day Parenting, Good Parenting Skills, Parenting a
Teenager, etc), so I get all 6 Book Titles ?
I tried Like "*" Or [Enter Partial Title of Book] & "*" but it returns
the entire database's Book Titles. Help.

To find the phrase anywhere in the field:
Like "*" & [Enter Partial Title of Book] & "*"

To find the phrase only at the beginning of the field:
Like [Enter Partial Title of Book] & "*"

To find the phrase only at the end of the field:
Like "*" & [Enter Partial Title of Book]
 
J

John Spencer

Try the following

WHERE Title Like "*" & Nz([Enter Partial Title of Book],"xjxjyz") & "*"
OR Title Like "*" & NZ([Enter Second Partial],"xjxjyz") & "*"

If you are using the query grid you would have to use two parameters on two
lines
Field: Title
Criteria(Line1): Like "*" & Nz([Enter Partial Title of Book],"xjxjyz") & "*"
Criteria(Line2): Like "*" & Nz([Enter Second Partial],"xjxjyz") & "*"

The NZ puts xjxjyz into the search string if you leave the prompt blank. If
you didn't put in a nonsense string, then you would end up matching all
titles in the database.
 
T

Tall Mary

John, I love you.
Geez, you guys on this Discussion Group are Blindingly Brilliant.
Thank you, Thank you, Thank you.
How did you know about putting the gibberish in the query ??


John Spencer said:
Try the following

WHERE Title Like "*" & Nz([Enter Partial Title of Book],"xjxjyz") & "*"
OR Title Like "*" & NZ([Enter Second Partial],"xjxjyz") & "*"

If you are using the query grid you would have to use two parameters on two
lines
Field: Title
Criteria(Line1): Like "*" & Nz([Enter Partial Title of Book],"xjxjyz") & "*"
Criteria(Line2): Like "*" & Nz([Enter Second Partial],"xjxjyz") & "*"

The NZ puts xjxjyz into the search string if you leave the prompt blank. If
you didn't put in a nonsense string, then you would end up matching all
titles in the database.


Tall Mary said:
I have a Book Database with one field named Titles.
Is it possible to make a query using 2 partial names in the field name to
get all the matching items I want in one query?
For example, *Gone* (Gone Fishing, Gone with the Wind, Gone Crazy, etc)
and
*Parenting*(for Modern Day Parenting, Good Parenting Skills, Parenting a
Teenager, etc), so I get all 6 Book Titles ?
I tried Like "*" Or [Enter Partial Title of Book] & "*" but it returns
the entire database's Book Titles. Help.
 
J

John Spencer

Best I can say is experience. I've been doing this quite a while.


Tall Mary said:
John, I love you.
Geez, you guys on this Discussion Group are Blindingly Brilliant.
Thank you, Thank you, Thank you.
How did you know about putting the gibberish in the query ??


John Spencer said:
Try the following

WHERE Title Like "*" & Nz([Enter Partial Title of Book],"xjxjyz") & "*"
OR Title Like "*" & NZ([Enter Second Partial],"xjxjyz") & "*"

If you are using the query grid you would have to use two parameters on
two
lines
Field: Title
Criteria(Line1): Like "*" & Nz([Enter Partial Title of Book],"xjxjyz") &
"*"
Criteria(Line2): Like "*" & Nz([Enter Second Partial],"xjxjyz") & "*"

The NZ puts xjxjyz into the search string if you leave the prompt blank.
If
you didn't put in a nonsense string, then you would end up matching all
titles in the database.


Tall Mary said:
I have a Book Database with one field named Titles.
Is it possible to make a query using 2 partial names in the field name
to
get all the matching items I want in one query?
For example, *Gone* (Gone Fishing, Gone with the Wind, Gone Crazy, etc)
and
*Parenting*(for Modern Day Parenting, Good Parenting Skills, Parenting
a
Teenager, etc), so I get all 6 Book Titles ?
I tried Like "*" Or [Enter Partial Title of Book] & "*" but it
returns
the entire database's Book Titles. Help.
 
Top