Solved

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

Posted on 2014-07-20
2
1,598 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
Comment Utility
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
Comment Utility
Excellent answer. Thanks alot
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
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…

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

16 Experts available now in Live!

Get 1:1 Help Now