Article ID: 214827 - Last Review: July 27, 2006 - Revision: 2.3 How to use nested IF fields in a mail-merge document in Word 2000 or Word 2002This article was previously published under Q214827 For a Microsoft Word 98 Macintosh Edition version of
this article, see
189018
(http://support.microsoft.com/kb/189018/
)
. For a Microsoft Word 97 version of this article, see
90393
(http://support.microsoft.com/kb/90393/
)
. On This PageSUMMARY In Microsoft Word 2000 or in Microsoft Word 2002, you can use the IF field to obtain customized
mail-merge results. By nesting IF fields, as described in this article, you can
obtain conditional mail-merge results and logically construct the equivalent of
Boolean AND and OR statements. MORE INFORMATION The IF field syntax is as follows
{IF Exp Op Exp TrueResult [FalseResult]}
where TrueResult and
FalseResult can be either text or a nested IF field.
If you do not include the FalseResult argument, Word
returns nothing if the result is false. Conditional print merge results using IF fieldIn the following example, each form letter requests that its recipient attend a meeting on a different date, based on the city field.Data document
NAME, ADDRESS, CITY, STATE, ZIP Robert Brown, 123 Acorn St., Seattle, WA, 98035 Megan Sherman, 234 Ash St., Los Angeles, CA, 99888 Mike Tiano, 345 Birch Ave., San Francisco, CA, 45555 Suanne Nagata, 456 Walnut St., Boise, ID, 83240 Main document
Please attend the Windows meeting on {if {city}= "Seattle" "Tuesday,
March 21." "{if {city}= "Los Angeles" "Wednesday, March 22." {if {city}=
"San Francisco" "Thursday, March 23." "Friday, March 24."}"}"}.
Merged results
(for Mr. Brown) Please attend the Windows meeting on Tuesday, March 21. (for Ms. Sherman) Please attend the Windows meeting on Wednesday, March 22. (for Mr. Tiano) Please attend the Windows meeting on Thursday, March 23. (for Ms. Nagata) Please attend the Windows meeting on Friday, March 24. Using IF field to perform boolean AND and OR operationsThe IF field does not directly support Boolean AND and OR operations in a mail merge. However, the logical AND and OR operators are actually just abbreviations of nested IF statements; therefore, you can construct the equivalent of Boolean AND and OR operations.Starting with the basic IF statement
{IF test1 "TrueResult" "FalseResult"}
you can nest another IF statement to create a logical OR or AND statement as in the following examples:
Constructing a boolean AND statementThis AND statement
{IF field <> "A" "{IF field <> "B" "TrueResult" "FalseResult"}"
"FalseResult"}
Constructing a boolean OR statementThis OR statement
{IF field = "A" "result" "{IF field = "B" "TrueResult"
"FalseResult"}"}
| Article Translations
|

Back to the top
