VBA code open access database

jakobt

Active Member
Joined
May 31, 2010
Messages
337
My access database does not open. Any clue why? I have put refence to Microsoft activeX data objects 6.1 Library. I use Microsoft access 2016:

sub copydata()
dim accessdb as adodb.connection
dim accessdata as adodb.recordset

set accessdb = new adodb.connection
set accessdata = new adodb.recordset

accessdb.connectionstring = "provider=Microsoft.ace.oledb.12.0;Data source= s:\smart.accdb"
accessdb.open

end sub
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Hi,
ADO is not a way to open a database, it rather is a way to connect to a database. So basically it is invisible and happens only in code or, as some would say, programmatically. Basically once you open a connection with ADO you have to do something with the connection - select data, update data, delete data, or insert data. With more code :)
 
Upvote 0
Option you could try is using a Shell command, example below:

Sub DBOpen()
Dim retval As String
Dim Filename As Variant
Filename = "s:\smart.accdb"
retval = Shell("msaccess.exe " & Filename, vbNormalFocus)
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,823
Messages
6,121,779
Members
449,049
Latest member
greyangel23

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