Expresion to find a sentence in a field containing multiple sente

A

Alexandra504

I have a querry in Access and I need an expresion that needs to find a group
of words in another field and return yes if it finds it and return blank if
it doen't find it. I have the following expression in which:

ADDED WORKLIFE REWARDS MEMBER: is the field name in the querry
Call_Comments is the field where it needs to search
ADDED WORKLIFE REWARDS MEMBER is the sentence that needs to search
"YES" is the outcome if it finds the sentence
" " is the outcome if it doen't find the sentence

This is the expresion that I have but since the Call_Comments field contains
more sentences all return to blank:

ADDED WORKLIFE REWARDS MEMBER: IIf([Call_Comments]="ADDED WORKLIFE REWARDS
MEMBER","YES"," ")
 
J

John Spencer

Try using Instr or Like in the IIF. My preference is to use LIKE in a
query.

ADDED WORKLIFE REWARDS MEMBER:
IIf([Call_Comments] Like "*ADDED WORKLIFE REWARDS MEMBER*","YES"," ")

OR
ADDED WORKLIFE REWARDS MEMBER:

IIf(Instr(1,[Call_Comments],"ADDED WORKLIFE REWARDS MEMBER",3)> 0,"YES","
")
 
K

Klatuu

ADDED WORKLIFE REWARDS MEMBER: IIf(Instr([Call_Comments], "ADDED WORKLIFE
REWARDS
MEMBER") <> 0,"YES"," ")
 
A

Alexandra504

It worked. Thank you so much

Klatuu said:
ADDED WORKLIFE REWARDS MEMBER: IIf(Instr([Call_Comments], "ADDED WORKLIFE
REWARDS
MEMBER") <> 0,"YES"," ")

Alexandra504 said:
I have a querry in Access and I need an expresion that needs to find a group
of words in another field and return yes if it finds it and return blank if
it doen't find it. I have the following expression in which:

ADDED WORKLIFE REWARDS MEMBER: is the field name in the querry
Call_Comments is the field where it needs to search
ADDED WORKLIFE REWARDS MEMBER is the sentence that needs to search
"YES" is the outcome if it finds the sentence
" " is the outcome if it doen't find the sentence

This is the expresion that I have but since the Call_Comments field contains
more sentences all return to blank:

ADDED WORKLIFE REWARDS MEMBER: IIf([Call_Comments]="ADDED WORKLIFE REWARDS
MEMBER","YES"," ")
 
A

Alexandra504

Thanks ... both expresions worked

John Spencer said:
Try using Instr or Like in the IIF. My preference is to use LIKE in a
query.

ADDED WORKLIFE REWARDS MEMBER:
IIf([Call_Comments] Like "*ADDED WORKLIFE REWARDS MEMBER*","YES"," ")

OR
ADDED WORKLIFE REWARDS MEMBER:

IIf(Instr(1,[Call_Comments],"ADDED WORKLIFE REWARDS MEMBER",3)> 0,"YES","
")


Alexandra504 said:
I have a querry in Access and I need an expresion that needs to find a
group
of words in another field and return yes if it finds it and return blank
if
it doen't find it. I have the following expression in which:

ADDED WORKLIFE REWARDS MEMBER: is the field name in the querry
Call_Comments is the field where it needs to search
ADDED WORKLIFE REWARDS MEMBER is the sentence that needs to search
"YES" is the outcome if it finds the sentence
" " is the outcome if it doen't find the sentence

This is the expresion that I have but since the Call_Comments field
contains
more sentences all return to blank:

ADDED WORKLIFE REWARDS MEMBER: IIf([Call_Comments]="ADDED WORKLIFE REWARDS
MEMBER","YES"," ")
 
Top