Solved

Accessing a .accdb file in Excel 2007 using VBA

Posted on 2012-12-24
2
2,346 Views
Last Modified: 2012-12-25
Class cCNXtoDB
Option Explicit

Const sDBpath = "C:\Users\ChopperDave64\Documents\Repair Busniess\DB\"
Const sDBfileName = "Repair Data Tracking.accdb"

Dim bDBopen As Boolean, bInit As Boolean
Dim dbRepairBus As DAO.Database

Private Sub Class_Initialize()
Dim bRes As Boolean
bRes = OpenDB()
Debug.Print "CCNXtoDB constructor OpenDB = " & bRes
End Sub

Function OpenDB() As Boolean
Set dbRepairBus = DAO.DBEngine.OpenDatabase(sDBpath & sDBfileName) ' <-- Causes run time error 3343

bDBopen = True
OpenDB = bDBopen
End Function

Open in new window


Test Function
Function TestClass() As Boolean
Dim RepairDB As CNXtoDB
Set RepairDB = New CNXtoDB
Debug.Print RepairDB.OpenDB
End Function

Open in new window


I've seen other discussions about run time error 3343, but none that I have read has helped me.

I am trying to open an MS Access 2007 .accdb file using VBA in Excel 2007.  I noted the offending line of code.

I thought this should be straight forward, but I don't understand why this is not working.  Any help is appreciated!

Thanks and Merry Christmas.
ee-question.jpg
0
Comment
Question by:AviationAce
2 Comments
 
LVL 39

Accepted Solution

by:
als315 earned 475 total points
ID: 38719675
You should remove reference to DAO 3.6 library and add reference to:
Microsoft Office 12 access database engine object library
0
 

Author Closing Comment

by:AviationAce
ID: 38719938
Perfection!  Thank you!
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

920 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now