Word 2010 - Mail Merge multiple conditions
I am attempting to get mail merge to process certain conditions eg: if mergefield spouse = 1 and mergefield lawyer = 2 and mergefield children = 3 and mergefield parent = 4 add certain text
or
if mergefield spouse = 1 and mergefield lawyer = 0 and mergefield children = 2 and mergefield parent = 0 add this text
etc So depending on the sequence of the mergefield would depend on the text add
I have tried the following but it doesnt seem to work { IF{=OR({COMPARE { MERGEFIELD "Spouse "}= "0"}, { COMPARE { MERGEFIELD "lawyer"} = "1" { COMPARE {MERGEFIELD "Children "}= "0" }, { COMPARE { MERGEFIELD "Parent"}= "0" })} = "1" "Lawyer Text" ""}
Or { IF{=OR({COMPARE { MERGEFIELD "Spouse "}= "1"}, { COMPARE { MERGEFIELD "lawyer"} = "3" { COMPARE {MERGEFIELD "Children "}= "2" }, { COMPARE { MERGEFIELD "Parent"}= "0" })} = "1" "Family 1 Text" ""}
Or
{ IF{=OR({COMPARE { MERGEFIELD "Spouse "}= "1"}, { COMPARE { MERGEFIELD "lawyer"} = "0" { COMPARE {MERGEFIELD "Children "}= "2" }, { COMPARE { MERGEFIELD "Parent"}= "3" })} = "1" "Family First Text" ""}
1 Answer
The basic IF syntax, can be nested to test multiple conditions.
Single Condition (basic):
{IF {MERGEFIELD FIELD1} = "CONDITION1" "TRUE" "FALSE"}Two Conditions:
{IF {MERGEFIELD FIELD1} = "CONDITION1" "{IF {MERGEFIELD FIELD2} = "CONDITION2" "TRUE" "FALSE2"}" "FALSE1"}Your Example:
{IF {MERGEFIELD SPOUSE} = "1" "{IF {MERGEFIELD LAWYER} = "0" "{IF {MERGEFIELD CHILDREN} = "2" "{IF {MERGEFIELD PARENT} = "0" "add this text" ""}" ""}" ""}" ""}