Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2014-07-20
2
Medium Priority
?
1,718 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 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

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

Question has a verified solution.

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

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

772 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