VBA to move Excel table into Access from excel.

Richard U

Active Member
Joined
Feb 14, 2006
Messages
406
Office Version
  1. 365
  2. 2016
  3. 2010
  4. 2007
Platform
  1. Windows
Situation:


  • Due to licensing issues, the user will not have the use of MS Access
  • A Link from Access to Excel is not possible due to company policy
  • Due to these issues, all code must reside in an Excel spreadsheet

Is there a way to have Excel VBA connect to a database then update a table with the contents of a table/sheet residing in Excel?

I know how to write the connection string...

Code:
dim StrSql as string
dim StrConnection  as string
Dim obj_Connection As Object

StrConnection = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=MyDrive:\Mypath\Reports\MyDatabase.accdb"
strSQL = (SQL CODE) +  ????


    obj_Connection.Open StrConnection  

    .......



So, what I need is either:

  1. How to design and execute the rest of the query
  2. VBA code/commands to set up a record set to send to the database.

It has been about 10 years since I've done any serious interoperability coding, so I'm rusty. I know what to do, I just need some help on how to do it.
 
Last edited:

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

Forum statistics

Threads
1,215,580
Messages
6,125,654
Members
449,245
Latest member
PatrickL

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