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

x
?
Solved

Automate the import of a spreadsheet into Access Database

Posted on 2012-03-27
5
Medium Priority
?
383 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 1200 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
 

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

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
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.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

926 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