No Column Headers in Excel

Moxioron

Registered User.
Local time
Today, 13:43
Joined
Jul 11, 2012
Messages
68
Hello.

I am trying to import an Excel spreadsheet into an Access table and running into a snag. Since the spreadsheet doesn't have column headers, I keep getting Run-time error '2391' - Field '0000000' doesn't exist in the destination table ... my table name.

How can I import the data from a spreadsheet so that it ignores the fact that there is no column headers?

Here is the VBA/Module:

Option Compare Database

Dim myCheck
Function WebRegistration()
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "tbl_TruRewards Web Registration", "R:\DEPT-BR\CONSUMER LENDING\VISA\Cardholder Activity\Web Registration_TruRewards.xls", True, "Web Registration!F8:R50000"
End Function
 
You do something revolutionary: look up the method in the docs (always a good starting point) :D
 
Change this:

DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "tbl_TruRewards Web Registration", "R:\DEPT-BR\CONSUMER LENDING\VISA\Cardholder Activity\Web Registration_TruRewards.xls", True, "Web Registration!F8:R50000"

to this

DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "tbl_TruRewards Web Registration", "R:\DEPT-BR\CONSUMER LENDING\VISA\Cardholder Activity\Web Registration_TruRewards.xls", False, "Web Registration!F8:R50000"
 
Some may think Spike a little unhelpful but it took less than 10 seconds on Google to find this

http://msdn.microsoft.com/en-us/library/office/ff844793(v=office.15).aspx

which contains this


HasFieldNames

Optional

Variant

Use True (–1) to use the first row of the spreadsheet as field names when importing or linking. Use False (0) to treat the first row of the spreadsheet as normal data. If you leave this argument blank, the default (False) is assumed. When you export Access table or select query data to a spreadsheet, the field names are inserted into the first row of the spreadsheet no matter what you enter for this argument.

This plus the rest of the info is more useful than having somebody do the work.

Brian
 

Users who are viewing this thread

Back
Top Bottom