WD: Using Comparison IF Statements with Text and Numbers

Last reviewed: February 5, 1998
Article ID: Q75950
The information in this article applies to:
  • Microsoft Word for the Macintosh, versions 3.0, 3.01, 3.02, 4.0, 5.0, 5.1, 5.1a

SYMPTOMS

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

CAUSE

In your data file, a particular field contains text with some records and numbers with other records.

MORE INFORMATION

When the comparison is set up to select a number greater or less than another value, such as <<if score>"70">> <<score>> <<endif>>, 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 two IF statements: one that restricts text and one that returns the correct numeric value. For example:

   <<if score<"A">> <<if score>"70">> <<score>> <<endif>> <<endif>>

Requesting text less than A returns no text, and requesting scores greater than 70 returns only the scores with numeric values over 70.

If the comparison information does not include quotation marks, the error message "Not a valid integer for comparison" will appear.

For example, the statement

   <<if score>70>> <<score>> <<endif>>

should read

   <<if score>"70">> <<score>> <<endif>>

For more information on print merging and IF statements, please see the following articles in the Microsoft Knowledge Base:

   ARTICLE-ID: Q141008
   TITLE     : WD: How to Force Text to Start at Same Line in Merged
               Letters

   ARTICLE-ID: Q122505
   TITLE     : WD: Selecting "(None)" Resets Filter Comparison

   ARTICLE-ID: Q113314
   TITLE     : WD: Word Err Msg: Word Could Not Parse Your Query Options

   ARTICLE-ID: Q97795
   TITLE     : WD: Using Print Merge to Create a List Sorted by Category

   ARTICLE-ID: Q66612
   TITLE     : WD: Second Expression in Conditional Print Merge Statement

   ARTICLE-ID: Q63687
   TITLE     : WD: Comparing Dates During Print Merge


Additional query words: printmerge filemerge
Keywords : kbmerge macword macword5 kbprint
Version : MACINTOSH:3.0,3.01,3.02,4.0,5.0,5.1,5.1a
Platform : MACINTOSH
Issue type : kbinfo


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