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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query to search memo fields 2

Status
Not open for further replies.

crisis2007

Technical User
Joined
Apr 2, 2007
Messages
114
Location
US
Is there a way to perform a word search of records containing memo fields? I want to return all the records that have a particular word in the memo fields (The memo fields have several words - sentences in them). I have the following in my query:

SELECT T_Activity.ActivityDate, T_Event.CaseNumberCMS, T_Event.CaseNumberARS, T_Event.Time, T_Event.Narrative
FROM T_Activity INNER JOIN T_Event ON T_Activity.ActivityKey = T_Event.ActivityKey
WHERE (((T_Activity.ActivityDate) Between [Forms]![F_SearchNarrative]![StartDate] And [Forms]![F_SearchNarrative]![EndDate]) AND ((T_Event.Narrative)=[Forms]![F_SearchNarrative]![txtSearchWord]));

However I realize I get nothing back as it is looking for an exact match where the word I am searching is the only word in the field. Is there a way to write this in the query so it returns the records that includes the word I am looking for?
 
Try:

[tt]...
WHERE (((T_Activity.ActivityDate) Between [Forms]![F_SearchNarrative]![StartDate] And [Forms]![F_SearchNarrative]![EndDate]) AND ((T_Event.Narrative) LIKE "*" & [Forms]![F_SearchNarrative]![txtSearchWord] & "*"));[/tt]
 
yes, use LIKE:
Code:
WHERE SomeField LIKE "*Something*"

this will find the word Something anywhere in the field. the rules of LIKE are:

AP* Finds all records where the information STARTS with AP:
APple
APply

*AP finds all records where the information ENDS with AP
cAP
tAP

*AP* finds all records that CONTAIN AP
Apple
Apply
Cap
Tap
Capers

HTH


Leslie

Have you met Hardy Heron?
 
Thank you both. It works just as I needed. And thanks for explaining the rules for like. I was unclear on how that worked before. Thanks again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top