Solved

How import certain Excel columns into table in Access

Posted on 2013-06-05
7
1,843 Views
Last Modified: 2013-06-05
I need to find a way to import certain columns of an Excel file into an Access table.

Here are the specifics:

1) The Excel file will always be in a specific folder on the user's desktop named "Import Files".
2) There will be only one Excel file in the folder.
3) The data to import will always be in "Sheet1"
4) This may change but for example I need columns A, B, C, D, F, and G
5) The first column will hold the primary key field.
6) The name of the table the data is to import into is "tblImports"

The is one more challenge to this but I'll ask in it a separate topic once this topic has been resolved.
0
Comment
Question by:SteveL13
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 39223096
I generally use the TransferSpreadsheet method to import all of the fields into a staging table (tblStageExcelData), then I use a query to append only the fields I need into my destination table (tblImports).  This allows me to use the built in conversion functions to ensure that the data that ends up in my destination table is in the correct format.
0
 

Author Comment

by:SteveL13
ID: 39223223
I must be doing something wrong.  What is wrong with this?

DoCmd.TransferSpreadsheet acImport, 3, "tblTempImport", "C:\ImportFiles\ImportFile.xlsx", True

(I'm using Access 2010)
0
 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 total points
ID: 39223270
I don't see '3' being an option for the spreadsheet type argument.  Try:

DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12, "tblTempImport", "C:\ImportFiles\ImportFile.xlsx", True
0
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

Author Comment

by:SteveL13
ID: 39223295
That did work.  But a question...  will acSpreadsheetTypeExcel12 work for Access 2007 as well as 2010?
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 39223304
Yes.
0
 

Author Comment

by:SteveL13
ID: 39223324
Thank you very much.
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 39223434
welcome.
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question