?
Solved

Accessing a .accdb file in Excel 2007 using VBA

Posted on 2012-12-24
2
Medium Priority
?
2,499 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 40

Accepted Solution

by:
als315 earned 1900 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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

752 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