Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Importing Excel File into access as a table

Status
Not open for further replies.

math20

MIS
Jul 7, 2005
71
CA
Hi

I am trying to import an excel file into access. Until this morning I was able to do that just fine, but all of a sudden I am getting this error:
"The action requires a Table Name argument"

This is my code:
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "", strFileName, True

Why would it work all this time and just stop working now?

Please help.
Thanks.
 
Hi after checking out your code you forgot to specify the name of the Access table right after the specification of the type of spreadsheet e.g.
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9,NameOfTable,strFileName,, True
 
Yes I realize that but I never specified the table name before and it wotked, when it imported the excel file it would assign this "_" as the table name and I just renamed it. But now even if I specify a table name that I want to import it to it says Too many fields defined. The fact is once the excel file is imported I run some delete queries to clean it up and then use that to run some other queries for my reporting purpose.

So I am not sure what went wrong. This does look like a bug, I am glad I got it now than later. Any other suggestion?
 
hi

How can we do the other way meaning how can we export the results into an excel file
 
In the VBA help file have a look at the first argument of the DoCmd.TransferSpreadsheet method.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top