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
Solved

How import certain Excel columns into table in Access

Posted on 2013-06-05
7
1,778 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
  • 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

840 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