WD: How to Specify Multiple Conditions with a Nested IF Field

Last reviewed: February 18, 1998
Article ID: Q177287
The information in this article applies to:
  • Microsoft Word 97 for Windows
  • Microsoft Office 98 Macintosh Edition

SUMMARY

In a mail merge main document, you can use an IF (IF...THEN...ELSE) conditional statement to check whether one condition or multiple conditions are met. This article provides a method of nesting COMPARE statements in an IF field to test whether the desired conditions are met.

MORE INFORMATION

You can specify multiple conditions by nesting a COMPARE field inside an IF field.

To Test Whether Multiple Conditions Are Met

To test whether multiple fields meet certain conditions, you could use an AND conditional statement in your mail merge main document similar to the following:

   { IF { = AND ( { COMPARE { MERGEFIELD Field_1 } = <Value> }, { COMPARE
   { MERGEFIELD Field_2 } = <Value> } ) } = 1 "<True Instructions>"
   "<False Instructions>"}

The result of these nested COMPARE statements would be the <True Instructions> when both Field_1 and Field_2 are equal to <Value>; otherwise, the <False Instructions> would be given as the result.

NOTES:

  • When all of the conditions of the AND statement are met, the value returned by the statement would be equal to 1 (this would result in the True Instructions being returned).
  • When all of the conditions of the AND statement are not met, the value returned by the statement would be equal to 0 (this would result in the False Instructions being returned).

To Test Whether One Condition Is Met

To test whether one of the fields meets a particular condition, you could use an OR conditional statement in your mail merge main document similar to the following:

   { IF { = OR ( { COMPARE { MERGEFIELD Field_1 } >= <Value> }, { COMPARE
   { MERGEFIELD Field_2 } >= <Value> } ) } = 1 "<True Instructions>"
   "<False Instructions>"}

The result of these nested COMPARE statements would be the <True Instructions> when either Field_1 or Field_2 is equal to <Value>; otherwise, the <False Instructions> would be given as the result.

NOTES:

  • When any of the conditions of the OR statement is met, the value returned by the statement would be equal to 1 (this would result in the True Instructions being returned).
  • When all of the conditions of the OR statement are not met, the value returned by the statement would be equal to 0 (this would result in the False Instructions being returned).

REFERENCES

For more information about conditional statements, click the Office Assistant, type "advanced mail merge," and then click to view "Customize documents created with mail merge."

NOTE: If the Assistant is hidden, click the Office Assistant button on the Standard toolbar. If Microsoft Help is not installed on your computer, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q120802
   TITLE     : Office: How to Add/Remove a Single Office Program or
               Component

For additional information, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q90393
   TITLE     : WD: How to Use Nested IF Fields in a Print Merge Document

   ARTICLE-ID: Q176881
   TITLE     : WD: Err Msg: "Fields Are Nested Too Deeply" in a Mail Merge


Additional query words: word97 word8 8.0 mailmerge
Keywords : kbfield kbmerge word8 word97 macword98
Version : WINDOWS:97
Platform : WINDOWS
Issue type : kbhowto


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: February 18, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.