ACC2000: TransferSpreadsheet May Not Allow the Table Append Operation (208380)
The information in this article applies to:
This article was previously published under Q208380 Moderate: Requires basic macro, coding, and interoperability skills.
This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).
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.
Run-time error '2391':
Field 'F1' doesn't exist in destination table 'tablename.'
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.
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- Import the spreadsheet into a new table named tblTemp.
- Create an append query to append the data in the tblTemp table to your existing table.
- Run the append query.
- Delete the tblTemp table.
Method 2- 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.
- 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
- 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
REFERENCESFor 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
Modification Type: | Major | Last Reviewed: | 6/24/2004 |
---|
Keywords: | kb3rdparty kberrmsg kbinterop kbprb KB208380 |
---|
|