Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

ACC2000: TransferSpreadsheet May Not Allow the Table Append Operation


View products that this article applies to.

Symptoms

When you append data from a spreadsheet to an existing table by using a TransferSpreadsheet macro action or a TransferSpreadsheet method in Visual Basic for Applications, you may receive one of the following error messages:
Field 'F1' doesn't exist in destination table 'tablename.'

Microsoft Access was unable to complete the append operation. The destination table must contain the same fields as the table you are pasting from.
-or-
Run-time error '2391':

Field 'F1' doesn't exist in destination table 'tablename.'

↑ Back to the top


Cause

The first row of the spreadsheet file does not contain field names; therefore, Microsoft Access assumes the fields are named "F1," "F2," and so on.

↑ Back to the top


Resolution

You can use one of the following two methods to work around this behavior. You can import the spreadsheet into a new table, and then append that data in Microsoft Access; or you can change the spreadsheet to include field names in the first row.

Method 1

  1. Import the spreadsheet into a new table named tblTemp.
  2. Create an append query to append the data in the tblTemp table to your existing table.
  3. Run the append query.
  4. Delete the tblTemp table.

Method 2

  1. In Microsoft Excel, insert a new first row in the spreadsheet. In this row, add field names that match the field names in the existing Microsoft Access table.
  2. In the macro, change the Has Field Names argument to Yes, for example:
    Transfer Type: Import
    Spreadsheet Type: My_type
    Table Name: MyDatabaseTable
    File Name: pathname\filename
    Has Field Names: Yes
  3. If you are using code, the HasFieldNames argument should be set to True, for example:
    DoCmd.TransferSpreadsheet acImport, _
       <type of file to import>, "<MyDatabaseTable>", _
       <name of file including path>", True
    					

↑ Back to the top


More information

Steps to Reproduce Behavior

CAUTION: If you follow the steps in this example, you modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file and follow these steps on a copy of the database.

  1. Start Microsoft Excel and create a spreadsheet with the following data:
    A1: 9
    A2: Express
    A3: 800-123-4567
    B1: 10
    B2: US Mail
    B3: 800-569-4568
  2. Save the spreadsheet as C:\test1.xls.
  3. Start Microsoft Access, and then open the sample database Northwind.mdb or the sample project NorthwindCS.adp.
  4. Create a macro with the TransferSpreadsheet action and the following action arguments:
    Transfer Type: Import
    Spreadsheet Type: Microsoft Excel 8-9
    Table Name: Shippers
    File Name: C:\test1.xls
    Has Field Names: No
  5. Save the macro as TestImport, and then run the macro. Note that you receive the error mentioned in the "Symptoms" section.

↑ Back to the top


References

For additional information about unexpected behavior with the TransferSpreadsheet action, click the article number below to view the article in the Microsoft Knowledge Base:
197525 ACC2000: Can't Import Numeric Field Names with TransferSpreadsheet

For additional information about unexpected behavior when importing data from Excel, click the article number below to view the article in the Microsoft Knowledge Base:
208582 ACC2000: 'Field 'F1' Doesn't Exist in Destination Table' Err Msg

↑ Back to the top


Keywords: KB208380, kb3rdparty, kbprb, kbinterop, kberrmsg

↑ Back to the top

Article Info
Article ID : 208380
Revision : 2
Created on : 6/24/2004
Published on : 6/24/2004
Exists online : False
Views : 340