The information in this article applies to:
SUMMARYIn Word, 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 INFORMATIONThe 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, ZIPMain Document: Please attend the Windows meeting on {if {city}= "Seattle"Merged Results: (for Mr. Brown) 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 using the following syntax:
{IF test1 "TrueResult" "{IF test2 "TrueResult" "FalseResult"}"} {IF test1 "{IF test2 "TrueResult" "FalseResult"}" "FalseResult"} Constructing a Boolean AND StatementThis AND statement
can be translated to an IF statement for use in a mail merge as follows:
Constructing a Boolean OR StatementThis OR statement
can be translated to an IF statement for use in a mail merge as follows:
REFERENCES
"Microsoft Word for Windows User's Guide," version 2.0, pages 639-644
Additional query words: 2.0 word7 word6 7.0 word95 6.0 winword winword2 mailmerge mail merge how to
Keywords : kbdta wordnt kbfield winword kbmerge ntword macword word6 winword2 word7 word95 |
Last Reviewed: October 21, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |