WD: How to Use Nested IF Fields in a Print Merge Document |
Q189017
In 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.
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.
NAME, ADDRESS, CITY, STATE, ZIPMain Document:
Bill Brown, 123 Acorn St., Seattle, WA, 98035
Sandy Sill, 234 Ash St., Los Angeles, CA, 99888
Fred Turner, 345 Birch Ave., San Francisco, CA, 45555
Lynne Lowe, 456 Walnut St., Boise, ID, 83240
Please attend the Windows meeting on {if {city}= "Seattle"Merged Results:
"Tuesday, March 21." "{if {city}= "Los Angeles" "Wednesday, March
22." {if {city}= "San Francisco" "Thursday, March 23." "Friday,
March 24."}"}"}.
(for Mr. Brown)
Please attend the Windows meeting on Tuesday, March 21.
(for Ms. Sill)
Please attend the Windows meeting on Wednesday, March 22.
(for Mr. Turner)
Please attend the Windows meeting on Thursday, March 23.
(for Ms. Lowe)
Please attend the Windows meeting on Friday, March 24.
{IF test1 "TrueResult" "{IF test2 "TrueResult" "FalseResult"}"}
{IF test1 "{IF test2 "TrueResult" "FalseResult"}" "FalseResult"}
IF (field <> "A") AND (field <> "B") THEN
"TrueResult"
ELSE
"FalseResult"
END IF
can be translated to an IF statement for use in a mail merge as follows:
{IF field <> "A" "{IF field <> "B" "TrueResult" "FalseResult"}"
"FalseResult"}
IF (field = "A") OR (field = "B") THEN
"TrueResult"
ELSE
"FalseResult"
END IF
can be translated to an IF statement for use in a mail merge as follows:
{IF field = "A" "result" "{IF field = "B" "TrueResult"
"FalseResult"}"}
"Microsoft Word for Windows User's Guide," version 2.0, pages 639-644
"Word for Windows Companion," version 2.0, Mark Crane and M. David
Stone and Alfred Poor, Microsoft Press, 1992, pages 584-85
"Word for Windows Companion," version 1.x, Mark W. Crane, The Cobb
Group, 1990, pages 608-609
"Microsoft Word for Windows and OS/2 Technical Reference," pages 41-
42, 66-67, 357
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
Issue type : kbhowto kbprb
Technology :
|
Last Reviewed: November 4, 2000 © 2001 Microsoft Corporation. All rights reserved. Terms of Use. |