Solved

Automate the import of a spreadsheet into Access Database

Posted on 2012-03-27
5
323 Views
Last Modified: 2012-04-01
I'm working on a very simple database that allows me to reduce hundreds of employee salary change records into the most recent for each employee.  

Each time we update this query/report, I need to re-import the spreadsheet.  Is there a way to automate this such that the user can click a button on a report (or form) that will prompt the user to 'browse' for the spreadsheet.  I'd like to automatically use Sheet1 of the selected spreadsheet and place it into T_SalaryHistory, overwriting the current file.

Does anyone know how to do that?
0
Comment
Question by:BBlu
  • 3
5 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 300 total points
ID: 37774483
There is sample code by Ken Getz for browsing here:
http://access.mvps.org/access/api/api0001.htm

And for importing here:

http://www.accessmvp.com/kdsnell/EXCEL_Import.htm#ImpBrowseFile

(And a simple alternative is to have a predetermined location for your Excel sheet, and link to it from Access - so that the data is available for querying, reports, etc.  You can replace the linked spreadsheet when needed)
0
 

Author Comment

by:BBlu
ID: 37774551
oh..great idea. I'll try that.  And look at the sample code.
0
 
LVL 21
ID: 37774703
0
 

Author Comment

by:BBlu
ID: 37792374
mbizup-

I am trying to use your code but get an error that is saying "Field1" doesn't exist.  Attached are images of both the error popup and the line of code on which the code apparently breaks.
RunTimeError-2391.jpg
LineOfError.jpg
0
 

Author Closing Comment

by:BBlu
ID: 37793561
I found the mistake I was making and altered it.  After doing so, the solution worked perfectly!  Thanks mbizup.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

914 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

12 Experts available now in Live!

Get 1:1 Help Now