Searching for different fields in Access Document

  • Thread starter Thread starter yourtrashhere
  • Start date Start date
Y

yourtrashhere

So basically, what I have is a bunch of words in one memo field, for
example:

dog cat cowboy tree flower

To search it, this is the code I have now.

' Check for LIKE Last Name
If Me.txtLastName > "" Then
varWhere = varWhere & "[LastName] LIKE """ & Me.txtLastName & "*" * "
AND "
End If

The only problem is what I search for needs to be "in order", for
example, if I search for dog, I'll get the table. But, if I seach for
tree, I won't because tree was not place first. Can you please help me?
Thanks a lot!
Reply With Quote
 
Put the search terms in separate text boxes. Then you can do something like:

WHERE (((LastName) Like "*" & [Forms]![frmSearch]![Find1] & "*" And
(LastName) Like "*" & [Forms]![frmSearch]![Find2] & "*" And (LastName) Like
"*" & [Forms]![frmSearch]![Find3] & "*" And (LastName) Like "*" &
[Forms]![frmSearch]![Find4] & "*"));
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access
 
There's only one search box with which I want to search. I don't
necessarily need to search for a few terms. I just want to search out
of order. So here's what my table looks like:

|NAME|TAGS |
|Bob |dog cat flower water|

With the code I have, I can only search for the record by using "dog".
I want to search for the record by using "water" or "flower" or "cat".
Not all three, just any one of them.
 
The search criteria should then read:

Like "*" & [Enter your Search Term] & "*"

or with a form:

WHERE (((LastName) Like "*" & [Forms]![frmSearch]![Find1] & "*"

Notice the: "*"

I've used a wildcard both before and after.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access
 

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

Similar Threads


Back
Top