Question : Word Mergefield If-Then-Else Statement

I am trying to conditionally display the spouse2 address if it is different then spouse1 address.  Both spouses are included in the same data record.

For instance, lets say:

Spouse1:  John Smith
Add1       12 Tent Rd
Add2
Add3
City          Atlantic City
State        NJ
ZipCode  075265

Spouse2:  Loretta Smith
Add1        68 Wake Dr
Add2        Suite 3625
Add3
State        Trenton
State        NJ
ZipCode   075155

I am trying to develop a conditional statement based on Add1.  If the same, then blank else print each address.  So if the address it the same I could do the following:

John and Loretta Smith
12 Tent Rd
Atlantic City, NJ 075265

If different address lines, then it should display Spouse1 and Spouse2 with separate name and addresses.  
 
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
If Spouse1.Add1 = Spouse2.Add1 then ""
Else
Spouse1.Name
Spouse1.Add1 chr(130 +
Spouse1.Add2 chr(13) +
Spouse1.Add3 chr(13) +
Spouse1.City, Spouse1.State, Spouse1.ZipCode 
chr(13)
chr(13)
Spouse2.Name
Spouse2.Add1 chr(130 +
Spouse2.Add2 chr(13) +
Spouse2.Add3 chr(13) +
Spouse2.City, Spouse2.State, Spouse2.ZipCode

Answer : Word Mergefield If-Then-Else Statement

You will need to display the field codes instead of the field results. You can toggle between the two views with Alt+F9. Merge fields will then look like:
{ MERGEFIELD MyField } instead of <>.

You then need to nest your merge fields, paragraphs and any other text inside an IF field. Note that the {} field pairs must be entered either with Ctrl+F9 or will appear when a field is is entered on the document.

The paragraph marks are shown here. You can toggle their visibiklity with the ¶ button. Also I may be wrong, but I don't think that a dot (full stop) is allowed in a field name, so I have omitted them.

{IF { MERGEFIELD Spouse1Add1 } <> { MERGEFIELD Spouse2Add1 } "{ MERGEFIELD Spouse1Name }¶
{ MERGEFIELD Spouse1Add1 }¶
{ MERGEFIELD Spouse1Add2 }¶
{ MERGEFIELD Spouse1Add3 }¶
{ MERGEFIELD Spouse1City }, { MERGEFIELD Spouse1State }, { MERGEFIELD Spouse1ZipCode }¶


{ MERGEFIELD Spouse2Name }¶
{ MERGEFIELD Spouse2Add1 }¶
{ MERGEFIELD Spouse2Add2 }¶
{ MERGEFIELD Spouse2Add3 }¶
{ MERGEFIELD Spouse2City }, { MERGEFIELD Spouse2State }, { MERGEFIELD Spouse2ZipCode }"¶
 }¶


Random Solutions  
 
programming4us programming4us