Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

code to import data to access 2013 database from excel 2013 file

Posted on 2014-07-20
2
Medium Priority
?
1,698 Views
Last Modified: 2014-07-20
hi

i have a code that  seems to be excellent and professional (a code that prevent duplicates and check headers etc.) to import data from an excel file (code source  there) but i don't understand how exact the code is working. the function name is "ImportSpreadsheet" and the code is  on  a modle with the name "basImportXLS". i try to call this function on form "form1" with no success. i will be very thankful if someone will help me to use this function. i attached the access database and an excel file that it's came with this code.
TestData.xlsx
ImportXLS.accdb
0
Comment
Question by:bill201
[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
2 Comments
 
LVL 85

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 2000 total points
ID: 40207919
The "basTest" module includes a method named "TestImport". That shows you exactly how to use it. You would essentially duplicate that code in the Click event of your Command0 button.

Obviously, you'd need to know the full path to the file before you run this line:

   Set xlb = Excel.Application.Workbooks.Open("C:\TestData.xlsx")
 
That said, I really don't see any need to automate an instance of Excel just to import data. Instead, use TransferSpreadsheet to move your data from the Excel sheet into a "staging" table, and then use standard VBA/SQL to check it and move it to your "live" tables.
0
 

Author Closing Comment

by:bill201
ID: 40207987
Excellent answer. Thanks alot
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

721 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