WD: How to query for ""?"" and ""*"" in Print Merge IF field

Last reviewed: February 5, 1998
Article ID: Q110282
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, version 7.0
  • Microsoft Word 97 for Windows

SUMMARY

The "?" and the "*" are wildcard characters in a print merge. If you want to query for a "?" or an "*" in a field, use the following syntax:

   {IF "?" = {mergefield} "truetext" "falsetext"}

   -or-

   {IF "*" = {mergefield} "truetext" "falsetext"}

Reversing the query in the IF statement allows Word to view the "?" and the "*" as literal text, rather than as wildcards.

MORE INFORMATION

Here is a sample data file:

Name    Number
Sue     ?
Dave    4
Ashley  43        3

Question Mark

If the Number field is a "?", print "no number", otherwise print the number.

{IF "?" = {mergefield number} "No number to print" "{mergefield number}"}

Form Letter Example:

Sue      No Number
Dave     4
Ashley   43         3

Asterisks

If the name is an *, print "No name", otherwise print the name.

{IF "*" = {mergefield name} "No name" "{mergefield name}"}

Sue Dave Ashley No Name


KBCategory: kbusage kbhowto
KBSubcategory: kbfield
Additional query words: winword2 1.0 1.10 1.10a 2.0 2.0a 2.0a-CD
winword 7.0 word95 word7 word6 2.0b 2.0c
6.0 print merge wrong wild card word97
Keywords : kbfield
Version : 1.x 2.x 6.0 6.0a 6.0c 7.0 97
Platform : WINDOWS


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.