Revise a mailmerge main letter

T

TomC

I have a main letter in mailmerge which I needed to modify by adding a
multiple "IF AND" condition. I'm sure there must be a better way than the
way I did it. I used the Insert Word Field and finally got it modified to
state {IF {= AND ( {COMPARE { MERGEFIELD etc. Is there some way I could just
key in this "AND" function without using the "Insert Word Field"? Thanks.
 
D

Doug Robbins - Word MVP

You can use Ctrl+F9 to insert the necessary field delimiters { } and then
type in the expression that you want to use.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
M

macropod

Hi Tom,

You almost certainly don't need the COMPARE expression. Plus, Word's AND
expression is limited to combining two statements. An alternative construct,
which avoids both the COMPARE expression and the AND expression, is:
{IF{IF{MERGEFIELD Field_One}= "Cond1" 1 0}*{IF{MERGEFIELD Field_Two}=
"Cond2" 1 0}= 1 “Both conditions met” “At least one condition not met”}
Here, the '*' performs the same function as an AND expression. You can
simply keep adding more statements, thus:
{IF{IF{MERGEFIELD Field_One}= "Cond1" 1 0}*{IF{MERGEFIELD Field_Two}=
"Cond2" 1 0}*{IF{MERGEFIELD Field_Three}= "Cond3" 1 0}= 1 “All conditions
met” “At least one condition not met”}

A slight variation on this allows you to create the equivalent of an OR
expression:
{IF{IF{MERGEFIELD Field_One}= "Cond1" 1 0}+{IF{MERGEFIELD Field_Two}=
"Cond2" 1 0}> 0 “At least one condition met” “No conditions met”}
and:
{IF{IF{MERGEFIELD Field_One}= "Cond1" 1 0}+{IF{MERGEFIELD Field_Two}=
"Cond2" 1 0}+{IF{MERGEFIELD Field_Three}= "Cond3" 1 0}> 0 “At least one
condition met” “No conditions met”}
or even:
{IF{IF{MERGEFIELD Field_One}= "Cond1" 1 0}+{IF{MERGEFIELD Field_Two}=
"Cond2" 1 0}+{IF{MERGEFIELD Field_Three}= "Cond3" 1 0}> 1 “At two conditions
met” “At least two conditions not met”}
Here, the '+' performs the same function as an OR expression. Plus, as you
can see from the last example, it allows you to do much more than a simple
OR expression ever could.

Cheers
 

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

Top