How to Suppress Blank Fields in a Text Merge

Last reviewed: August 28, 1995
Article ID: Q121411
The information in this article applies to:
  • Microsoft FoxPro for Windows, versions 2.5x, 2.6, 2.6a
  • Microsoft FoxPro for MS-DOS, versions 2.0, 2.5x, 2.6, 2.6a
  • Microsoft FoxPro for Macintosh, versions 2.5x, 2.6a

SUMMARY

You can suppress blank fields in a FoxPro text merge by programmatically creating the TEXTMERGE command and then using macro substitution to execute the command, as shown in the example below.

MORE INFORMATION

This example assumes that you have a table with three fields

   NAME
   ADDRESS1
   ADDRESS2

and that you want to perform a text merge that produces output in the following format:

   <Name>
   <Address1>
   <Address2>
   <Date>

   <Body of letter>

If the ADDRESS2 field is empty, you want the date to appear directly underneath ADDRESS1, with no blank line where ADDRESS2 would normally appear.

The following program illustrates how to create the desired output.

   USE <table>
   SET TEXTMERGE TO outfile.txt
   SET TEXTMERGE ON
   SCAN
      * Test the ADDRESS2 field and return the appropriate text merge
      * character.
      cmnd=IIF(EMPTY(address2),"\\","\<<address2>>")
      \<<name>>
      \<<address1>>
      * Use macro substitution to execute the command.
      &cmnd
      \<<DATE()>>
      \
      \body of letter goes here
      * Print two empty lines between records.
      \
      \
   ENDSCAN
   SET TEXTMERGE OFF
   SET TEXTMERGE TO

REFERENCES

FoxPro "Language Reference," SET TEXTMERGE command


Additional reference words: FoxMac FoxDos FoxWin 2.00 2.50 2.50a 2.50b
2.50c 2.60
2.60a
print
merge printmerge textmerge suppressing empty extra extraneous
KBCategory: kbprg kbcode
KBSubcategory: FxprgMacrosub


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