?
Solved

Accessing a .accdb file in Excel 2007 using VBA

Posted on 2012-12-24
2
Medium Priority
?
2,586 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 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

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

864 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