Solved

How import certain Excel columns into table in Access

Posted on 2013-06-05
7
1,600 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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now