Using FoxPro Text Merge Feature with Multiple Databases

This article was previously published under Q94349
This article has been archived. It is offered "as is" and will no longer be updated.
Documents developed with the Text Merge feature can use fields from two ormore databases. The example below uses customer names and addresses fromthe FoxPro 2.x CUSTOMER.DBF sample database merged with form letterscontained in memo fields from a second database (INVOICE.DBF).
NOTE: This example only works using the FoxPro 2.x sample files.

The memo field contains all text to be merged. Page spacing (top, bottom,and side margins) is controlled within the memo field. A memo field canappear similar to the following example:
   <<DATE()>>   <<ALLTRIM(PROPER(CONTACT))>>   <<ALLTRIM(PROPER(COMPANY))>>   <<ALLTRIM(PROPER(ADDRESS))>>   <<ALLTRIM(PROPER(CITY))>>, <<ALLTRIM(STATE)>> <<ALLTRIM(ZIP)>>   Dear <<ALLTRIM(PROPER(CONTACT))>>:   This area includes the body of a letter to be   sent to the contact.   Sincerely,   Name   ENDTEXT				
The following program connects the information from the two databases. Workarea 1 includes the database (INVOICE) with memo fields that contain formletters. Work area 2 includes a database (CUSTOMER) that contains names andaddresses that should receive the letter. The program will execute fromwork area 2.

This example assumes that you have a customer database (CUSTOMER) withaccount status information and a database (INVOICE) with multiple formletters for different account statuses.
   SELECT 1   USE INVOICE   SELECT 2   USE CUSTOMER   CLEAR                               && Clear screen.   SET TEXTMERGE ON                    && Enable evaluation of components.   SET TALK OFF                        && Prevent printing of commands.   SET TEXTMERGE DELIMITERS TO         && Set default delimiters.   SET MEMOWIDTH TO 80                 && Set memo width for 80 columns.   SCAN                                && Force top-down processing.     FOR J=1 TO MEMLINES(invoice.memo)        X="\"+MLINE(invoice.memo,J)  && Process each line in memo field.        &X                        && Macro substitution.     ENDFOR   ENDSCAN				
VFoxWin FoxDos FoxWin form 2.x mail text merge functionality

Article ID: 94349 - Last Review: 02/28/2014 00:25:22 - Revision: 2.2

  • Microsoft Visual FoxPro 3.0 Standard Edition
  • Microsoft FoxPro 2.0
  • Microsoft FoxPro 2.5b for MS-DOS
  • Microsoft FoxPro 2.5a
  • Microsoft FoxPro 2.5b
  • Microsoft FoxPro 2.5a
  • kbnosurvey kbarchive KB94349