APPEND FROM <File> FOR Clause Requires Common Field

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

SUMMARY

When the APPEND FROM <file> command is used with the FOR clause, the conditions specified in the FOR clause must be met; in addition, if you are adding corresponding field values between tables, both files must contain identical field names.

MORE INFORMATION

When the APPEND FROM <file> command is used with the FOR clause, FoxPro performs two evaluations for adding records to the target file. Only records that both meet the FOR condition and contain identical field names in both the source and target files are added to the target file; records that do not meet one or both of these conditions are ignored during the APPEND request.

The following code example illustrates this behavior. In this example, records that contain the letter "C" in the company name are added from the CUSTOMER file to the ABC file. However, note that only those records that both meet the FOR clause and contain identical field names are added to the ABC file.

Sample Code

   SET DEFAULT TO SYS(2004)+"\Tutorial"
   USE Customer
   DISPLAY STRUCTURE
   *
   * Show current structure of CUSTOMER file
   *
   Structure for table:          c:\foxprow\tutorial\customer.dbf
   Number of data records:       60
   Date of last update:          05/26/94
    Field  Field Name      Type            Width      Dec    Index
        1  CNO             Character           5
        2  COMPANY         Character          35
        3  CONTACT         Character          20
        4  ADDRESS         Character          30
        5  CITY            Character          15
        6  STATE           Character           2
        7  ZIP             Character           5
        8  PHONE           Character          12
        9  ONO             Character           1
       10  YTDPURCH        Numeric             8        2
       11  LAT             Numeric             7        4
       12  LONG            Numeric             8        4
   ** Total **                               149
   *
   *
      SELECT Customer
      USE
      USE ABC
      DISPLAY STRUCTURE
   *
   * Show current structure of ABC file
   *
   *
   Structure for table:          c:\foxprow\tutorial\abc.dbf
   Number of data records:       60
   Date of last update:          05/26/94
    Field  Field Name      Type            Width      Dec    Index
        1  CNO_A           Character           5
        2  COMPANY         Character          35
        3  CONTACT         Character          20
        4  ADDRESS_A       Character          30
        5  CITY_A          Character          15
        6  STATE_A         Character           2
        7  ZIP_A           Character           5
        8  PHONE_A         Character          12
        9  ONO_A           Character           1
       10  YTDPURCHA       Numeric             8        2
       11  LAT_A           Numeric             7        4
       12  LONG_A          Numeric             8        4
   ** Total **                               149

   * Note that the COMPANY and CONTACT fields are common to both the
   * CUSTOMER and ABC files.

   * Program Example
      APPEND FROM SYS(2004)+"\tutorial\customer" FOR company = "C"

   * NOTE: Only CUSTOMER records containing a "C" in the COMPANY field are
   * added to the ABC file based on the common fields (COMPANY and CONTACT)
   * found in both the ABC and CUSTOMER files.


Additional reference words: FoxMac FoxDos FoxWin 2.00 2.50 2.50a 2.50b
2.50c 2.60 2.60a DBF database table same matching common
KBCategory: kbprg kbcode
KBSubcategory: FxprgGeneral


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