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

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

Posted on 2014-07-20
2
1,633 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
2 Comments
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
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…

790 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