WD: Using Comparison IF Statements with Text and Numbers

Last reviewed: February 18, 1998
Article ID: Q176769
The information in this article applies to:
  • Microsoft Word for the Macintosh, versions 6.0, 6.0.1, 6.0.1a
  • Microsoft Word 98 Macintosh Edition

SYMPTOMS

When you use the mail merge IF function for comparisons, the returned data may be different from what you expect.

CAUSE

This problem will occur if a field in the data source contains text in some records and numbers in other records.

WORKAROUND

When the comparison is set up to select a number greater or less than another value, such as {If {MERGEFIELD number} > 70 "True condition statement" "False condition statement"}, fields that contain text will also be printed. This is because Word considers all text to have a greater "value" than numbers.

To instruct Word to return only numeric values, use a nested IF statement. One that restricts text and one that returns the correct numeric value. For example:

   {If {MERGEFIELD number} > 70 "{If {MERGEFIELD NUMBER} < "A"
   "{MERGEFIELD number" " "} " "}

Word 6.x for the Macintosh

  {If {MERGEFIELD number} > 70 "{If {MERGEFIELD NUMBER} < "A"
  "{MERGEFIELD number" " "} " "}

The nested IF Statement requests text less than "A" and therefore returns no text in the field with text entries, and it then requests numbers greater than 70 for those records with numeric values over 70.

Word 98 Macintosh Edition

  {If {MERGEFIELD number} > 70 "{If {MERGEFIELD NUMBER} < "a"
  "{MERGEFIELD number" " "} " "}

The nested IF Statement requests text less than "a" and therefore returns no text in the field with text entries, and it then requests numbers greater than 70 for those records with numeric values over 70.

MORE INFORMATION

For information about this situation in earlier versions of Word, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q75950
   TITLE     : WD: Using Comparison IF Statements with Text and Numbers


Additional query words:
Keywords : kbfield kbmerge macword98
Version : MACINTOSH:6.0,6.0.1,6.0.1a
Platform : MACINTOSH
Issue type : kbprb
Solution Type : kbworkaround


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.