View Single Post
  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
AJ AJ is offline
external usenet poster
 
Posts: 36
Default string comparison

I was afraid of that. I will just go the route you suggested to do it in
Access then come into Word. I just didn't know if I was missing something.
Thank you for you time and knowledge.
Thanks

"Peter Jamieson" wrote:

The nearest the "Word field language" gets to "like" is that you can do

{ If {MergeField Reason} = "M*" "put this in" }

and

{ If {MergeField Reason} = "*M" "put this in" }

but unfortunately you cannot have wildcards at the beginning /and/ end
of the comparand, so you cannot do

{ If {MergeField Reason} = "*M*" "put this in" }

Approaches to work around this depend on the precise requirement but a
fairly general-purpose approach would be to create an Access query that
did the comparisons, returning additional columns, and use that as the
data source. e.g. something like

SELECT myfielda,iif(reason like '*M*',1,0) AS [containsM],myfieldb
FROM ...whatever...

then in word

{ If {MergeField containsM} = 1 "put this in" }


Peter Jamieson

http://tips.pjmsn.me.uk

AJ wrote:
I have a mailmerge document with a datasource of an Access Table. I am
needing help. I am wondering what the syntax of a "Like" comparison statement
would be in Word. I have a text field with multiple selections in it, and I
need a different statement for each one. So, what I want is Word to look at
this field and if it has a 1 in this text field put in this statement and so
on. But there can be more than one statement for each letter. I have done
like statements in Access but can't seem to find a syntax for it in Word.
Basically what I am wanting is somewhat listed below:
{If {MergeField Reason} Like *1*, "put this in"}
{If {MergeField Reason} Like *M*, "put this in"}
and so on. Any help would be greatly appreciated..

Thanks,
AJ