OpenDatabase command to .accdb 2007 Access Database not working (1 Viewer)

AlokOfAarmax

New member
Local time
Yesterday, 16:58
Joined
Apr 22, 2013
Messages
5
Hi Friends,

I normally use Excel to connect to 2003 format Access database. Even when i use Microsoft Access 2007 I have been making it a point to save the database in Access 2003 format. I use DAO to connect to the Access databases and have had DAO Object Library 3.6 reference in the IDE.

I have recently had to connect to Access 2007 and after much searching found that I had to install the 2007 Office System Driver: Data Connectivity Components. I did that.

I removed the reference to the DAO 3.6 Object Library but when I add a reference to to Microsoft Office 12.0 Access Database Engine Object Library I find that the following line does no longer complie:

Dim db as DAO.Database
Set db = OpenDatabase(xyz.accdb)

Can someone please guide me as to what is it that I am missing.

Thanks.

Alok
 

boblarson

Smeghead
Local time
Yesterday, 16:58
Joined
Jan 12, 2001
Messages
32,059
You don't want DAO 3.6. You want the Microsoft Office Access Database Engine 12.0 Object Library which is the more updated DAO reference for Office 2007.

EDIT: Oh, and you need to have your xyz.accdb in quotes and the path

Set db = OpenDatabase("C:\FolderHere\FileName")
 
Last edited:

AlokOfAarmax

New member
Local time
Yesterday, 16:58
Joined
Apr 22, 2013
Messages
5
Thanks Bob.
Yes I was referencing the correct library Microsoft Office Access Database Engine 12.0 Object Library but I was not able to get my code going. Then I saw that you have to do DBEngine.OpenDatabase. When I did that then the things starting working. I never tried this in the first place because I have always used
Set db = OpenDatabase("xyz.accdb") etc.
Any way thanks for your help. I greatly appreciate it. You are a genius and one day when I grow up I want to be like you.. (I am just in my 60s right now!! :))
Alok
 

Users who are viewing this thread

Top Bottom