WD: Example IF Fields for Print Merging in Word for Windows

Last reviewed: July 30, 1997
Article ID: Q70131
The information in this article applies to:
  • Microsoft Word for Windows, versions 1.1, 1.1a, 2.0, 2.0a, 2.0a-CD, 2.0b, 2.0c, 6.0, 6.0a, 6.0c
  • Microsoft Word for Windows 95, versions 7.0, 7.0a
  • Microsoft Word 97 for Windows

The following are examples of IF statements for print merging and the logic for each statement.

  1. {if {party}="R" "Republican" "Democrat or Other"}

    If "party" is equal to "R", enter "Republican" (first option is positive). If it is not equal to "R", enter "Democrat" or "Other" (second option is negative).

  2. {name} {if{party}<>"R" "" "Republican "}{City}

    If "party" is not equal to "R", enter nothing. If "party" is equal to "R", enter "Republican". This line will also suppress the blank line left by a non-R result.

  3. {if{party}="R" "Republican" {if{party"="D" "Democrat"} {if {party} ="O" "Other"}}

    If "party" is equal to "R", enter "Republican". If "party" is "D", enter "Democrat". If "party" is equal to "O", enter "Other". If "party" is none of these, it will be blank.

  4. {if{party}="R" "{party}epublican and family" {if{party}="D" "{party}emocrat and relatives" {if{party}="O" "{party}ther"}}}

    If "party" is equal to "R" then enter the value of "party" and "epublican and family". If "party" is equal to "D" then enter the value of "party" and "emocrat and relatives". If "party" is equal to "O" enter the value of "party" and "ther". If "party" is not "D", "R", or "O", it will be blank.

  5. {if{party}="R" {if{name}="George Bush" {if{city}="Washington D.C." "President"}}}

    If "party" is equal to "R" and "name" is "George Bush" and "city" is "Washington D.C.", enter "President". If all the conditions aren't met leave it blank.

Sample Data Document

NAME,PARTY,CITY George Bush,R,Washington D.C. George McGovern,D,Rapid City Gorgeous George,O,Hollywood King George,K,London

Special Note: Field codes and bookmarks are not case sensitive; for example, NAME would print merge to {naME}. However the results are case sensitive. In these examples if the codes said {if {party}="r" "Republican"} and the data document had the "r" capitalized (R), it would be considered to be a non-r and print nothing.


KBCategory: kbusage
KBSubcategory: kbfield kbmerge
Additional query words: 6.0 6.0a 6.0c winword2 word6 word7
winword 6.0a 6.0c 7.0 word95 word97

Keywords : kbfield kbmerge kbualink97 kbusage
Version : 1.10 1.10a 2.x 6.0 6.0a 6.0c
Platform : WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 30, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.