Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Macro to import data from excel to access

Posted on 2012-04-04
12
Medium Priority
?
231 Views
Last Modified: 2012-04-19
Hello everyone,

I have reports that come in on daily basis in form of Excel spreadsheet. I would like to set up a program or macro that would take values from these spreadsheet and store in access database. Additional information is the spreadsheet names will remain the same all the time and there is only one table to be updated..I can sit and write a macro but before that I felt that this is such a common task someone might have already done this..if yes please share..

Thank you.
0
Comment
Question by:Aiysha
[X]
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
  • 5
  • 4
  • 2
  • +1
12 Comments
 
LVL 9

Accepted Solution

by:
wasiftoor earned 2000 total points
ID: 37806366
You probably will not have to write a macro for this task. You can simply import the data any time from the Excel Spreadsheet and Access will automatically append the new data to the existing data for you utilizing an easy to use Wizard. Screenshot attached. Good Luck.

Import Excel Data In Access Database
0
 

Author Comment

by:Aiysha
ID: 37806412
Will this macro allow me to get data from specific "fixed" cell in excel into new row in access table?
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 37806421
you can use this command line

for Office2007 or office2010
docmd.transferspreadsheet acimport,10,"TableName","c:\folderName\myExcel.xlsx",True,"NameOfSheet!"


for Office2003
docmd.transferspreadsheet acimport,8,"TableName","c:\folderName\myExcel.xls",True,"NameOfSheet!"


you can call the codes in the clikc event of a button in a form or from a macro..
0
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 37806650
<Additional information is the spreadsheet names will remain the same all the time>
?
So what will be different for each file?
Please be specific or post two clear spreadsheet examples...

<there is only one table to be updated.>
Then you will may have to first import the data (with code similar to what capricorn1 posted)
Then run an "Append" query to add the new data to the existing table...

For example
Table1 is the existing Access table
Table2 is the imported Excel file
The query would look like this:

INSERT INTO Table1 ( SomeName, SomeNumber )
SELECT Table2.SomeName, Table2.SomeNumber
FROM Table2;

But again, you need to provide an example of a few of these "sequential" spreadsheets


This all being said, this becomes more complex because we don't know if the Excel file will always be the same or will be different for each import.
So you may need code to rename the files...

Again, we need more info and sample files...
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 37806828
i don't see the need for an APPEND query...
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 37808021
Perhaps not, but the OP did post:
"there is only one table to be updated"
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 37808042
"there is only one table to be updated",  so  where is the need for the APPEND query?
0
 

Author Comment

by:Aiysha
ID: 37808058
its updated on daily basis.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 37808228
What version of Office are you using?
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 37808244
capricorn1,
<where is the need for the APPEND query?>
As I said, I am not sure...
...to me, the term "Updated" and the statement:
<I have reports that come in on daily basis in>
...say that perhaps an append "Might" be needed...

In any event, the OP has just posted...
..perhaps you can ask them what is really needed here...?

Jeff
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 37808269
@jeff, see how the docmd.transferspreadsheet works..
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 37808380
No need, I have moved on

I'm sure you can handle this...
0

Featured Post

Does Your Cloud Backup Use Blockchain Technology?

Blockchain technology has already revolutionized finance thanks to Bitcoin. Now it's disrupting other areas, including the realm of data protection. Learn how blockchain is now being used to authenticate backup files and keep them safe from hackers.

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…
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

715 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