Solved

Accessing a .accdb file in Excel 2007 using VBA

Posted on 2012-12-24
2
2,315 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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,…
Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

708 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

11 Experts available now in Live!

Get 1:1 Help Now