WD: Example IF Fields for Print Merging in Word for Windows (70131)



The information in this article applies to:

  • Microsoft Word for Windows 1.1
  • Microsoft Word for Windows 1.1a
  • Microsoft Word for Windows 2.0
  • Microsoft Word for Windows 2.0a
  • Microsoft Word for Windows 2.0b
  • Microsoft Word for Windows 2.0c
  • Microsoft Word for Windows 6.0
  • Microsoft Word for Windows 6.0a
  • Microsoft Word for Windows 6.0c
  • Microsoft Word for Windows 95
  • Microsoft Word for Windows 95 7.0a
  • Microsoft Word 97 for Windows

This article was previously published under Q70131
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.

Modification Type:MinorLast Reviewed:8/16/2005
Keywords:kbfield kbmerge kbualink97 kbusage KB70131