WD: Conditional Alphanumeric Merge May Yield Incorrect Results

Last reviewed: February 2, 1998
Article ID: Q97484
The information in this article applies to:
  • Microsoft Word for Windows, versions 1.0, 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 for the Macintosh, versions 6.0, 6.0.1, 6.0.1a
  • Microsoft Word 97 for Windows
  • Microsoft Word 98 Macintosh Edition

SYMPTOMS

A print merge or mail merge operation may yield incorrect results if you use a conditional statement to evaluate alphanumeric data when the first character of the data is numeric.

CAUSE

This happens because conditional statements (IF fields) evaluate only the first two characters of a numeric string.

MORE INFORMATION

For example, using the sample data file below, the following conditional statement incorrectly yields a true result for the first and second records, although only the second record satisfies the condition:

   {IF {MERGEFIELD NUMBER} = "1AB" "This is true"}

NOTE: The IF field evaluated only the first two characters (1A) of the numeric string.

Sample Data File

   ---------------------------------
   |  Rec_Num  |Name      |Number  |
   ---------------------------------
   |     1     |John      |1AA     |
   ---------------------------------
   |     2     |Bill      |1AB     |
   ---------------------------------
   |     3     |Fred      |2AA     |
   ---------------------------------
   |     4     |George    |ABC     |
   ---------------------------------

WORKAROUND

To work around this problem, use the appropriate method for your version of Word.

Word Versions 6.x, 7.x, 97, 98 Macintosh Edition

Modify the data so that each field begins with a non-numeric character. Then modify the conditional field in the main merge document to match the data.

  1. In the data document, add a character to the beginning of each data field that starts with a number. You can use any character, such as a parenthesis (you can also add one to the end of the field, so that it's easier to read) or an ampersand (&). This makes the first character in the number field a character instead of a numeral.

    Modified with parentheses:

    ---------------------------------

       |  Rec_Num  |Name      |Number  |
       ---------------------------------
       |     1     |John      |(1AA)   |
       ---------------------------------
       |     2     |Bill      |(1AB)   |
       ---------------------------------
       |     3     |Fred      |(2AA)   |
       ---------------------------------
       |     4     |George    |(ABC)   |
       ---------------------------------
    
       Modified with an ampersand:
    
       ---------------------------------
       |  Rec_Num  |Name      |Number  |
       ---------------------------------
       |     1     |John      |&1AA    |
       ---------------------------------
       |     2     |Bill      |&1AB    |
       ---------------------------------
       |     3     |Fred      |&2AA    |
       ---------------------------------
       |     4     |George    |&ABC    |
       ---------------------------------
    
    

  2. In the main document, edit the test portion of the conditional field so that it matches the newly modified data. For example:

    If the data is surrounded by parentheses, modify the field to look like this:

    {IF {MERGEFIELD number} = "(1A)" "This is true"}

    If the data begins with an ampersand, modify the field to look like this:

    {IF {MERGEFIELD number} = "&1A" "This is true"}

Word Version 2.x

If your alphanumeric data contains entries that begin with a numeric character, use the print merge Record Selection feature to perform a conditional merge of the data. By setting record selection rules, you can merge only data records that meet the criteria you specify.

The disadvantage of this workaround is that you must perform multiple print merge operations if your main document contains more than one conditional statement for alphanumeric fields. In this case, you must modify your main document for each condition, change the Record Selection settings to evaluate each condition individually and then perform a separate print merge operation. The functionality of the Record Selection feature differs from that of an IF field, so you must modify your print merge procedure accordingly.

For example, the following procedure uses the Record Selection feature to perform a conditional print merge of the sample data file above. This procedure replaces the following conditional statement:

   {IF {MERGEFIELD TEST} = "1AB" "This is true"}

  • Attach the data file to the main document and then activate the main document.

  • On the File menu, click Print Merge, and then click Merge.

  • Click Record Selection.

  • In the Field Name list, click to select Test.

  • In the Is list, click to select Equal To.

  • In the Compared To box, type "1AB" (without the quotation marks) and then click Add Rule. Click OK.

  • Complete the print merge operation. For record 2, "This is true" should appear in the merged document.

    Word Version 1.x

    1. Sort your data file based on the field that contains entries that begin with a numeric character.

    2. Number your data records.

    3. Insert a conditional field, such as IF or NEXTIF, to print merge the correct data records.


  • Additional query words: winword2 numbers strings alphabetic
    Keywords : kbfield kbmerge winword word6 word7 word95 word97 kbualink97
    Version : WINDOWS:1.0,1.1,1.1a,2.0,2.0a,2.0a- CD,2.0b,2.0c,6.0,6.0a,6.0c,7.0,7.a;97;MACINTOSH:6.0,6.0.1,6.0.1a,98
    Platform : MACINTOSH 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 2, 1998
    © 1998 Microsoft Corporation. All rights reserved. Terms of Use.