Solved

Accessing a .accdb file in Excel 2007 using VBA

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

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

840 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