VBA import and append data to table

psrs0810

Well-known Member
Joined
Apr 14, 2009
Messages
1,109
I have been a user of Access for many years, but never built anything. How do I setup VBA to import and append data to a table?
Thanks
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
At the same time?
There really isn't a good direct way to do that. You can either do an Insert/Append (add new records), or an Update (update existing records), but not both simultaneously (unless you create some custom VBA code to loop through recordsets, etc).

If you need to do both, one way that I have seen done many times is to import the data to a blank temporary table. Then create two queries from this:
- One to identify changes (can do a Matched query against your existing permanent data table), and make those changes via an Update Query
- One to identify new records (can do an Unmatched query against your existing permanent data table), and add them via an Append Query

And then run each query.

People will often automate many of these steps via a Macro or VBA code.
 
Last edited:
Upvote 0
let me clarify
There will be a table called ChargeDetial, this table will house charges up to a certain date range. what I need to do, is import the latest file and append the information to this table.
 
Upvote 0
If, by Append, you simply mean "add new records to the table", you should just be able to Import the records directly into the table.
It is pretty straightforward. There is even a Wizard that will walk you through it.

Just go to the "External Data" menu, go to the "Import & Link" ribbon, and select the correct data source (Excel, Text file, etc), and it will initiate the Wizard.
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,212
Members
452,618
Latest member
Tam84

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top