Attempting to connect to a valid database from outside Access (Outlook / Excel) using DAO generates 3343 unrecognized database format error

Thanks for your site. Great information.

In short, I am trying to execute the following code from Outlook (2007), although it also does not work in Excel. Great access to INSIDE!

Sub Test Dim db As DAO.Database Dim rs As DAO.Recordset Const dbPath As String = "C:\Users\e574651.GLOBAL\Documents\Northwind 2007.accdb" On Error Resume Next Set db = DAO.OpenDatabase(dbPath) 'Set rs = db.OpenRecordset("customers") Debug.Print Err.Number, Err.Description End Sub 

3343 The format of the unrecognized database is 'C: \ Users \ e574651.GLOBAL \ Documents \ Northwind 2007.accdb'.

I can access this database during the day without using ADO, and I suspect the problem is the following ADO statement:

ADOConn.Provider = "Microsoft.ACE.OLEDB.12.0"

How to provide this function using DAO?

I have included a link to the DAO 3.6 library in my VBA preferences. I included other Microsoft 12.0 library libraries, so I either bound something or omitted something.

Any help would be greatly appreciated.

Thanks!

+4
source share
2 answers

The latest DAO libraries are in the format:

 Microsoft Office xx Access Database Engine Object Library 

So get rid of the 3.6 link and use the newer library. Then an example:

 Sub XLAccess() Dim ws As DAO.Workspace Dim db As DAO.Database Dim sDb As String Dim sSQL As String Dim qdf As QueryDef sDb = "Z:\Docs\Test.accdb" Set ws = DBEngine.Workspaces(0) Set db = ws.OpenDatabase(sDb) ''A stored query would be better sSQL = "Parameters p1 Text, p2 Datetime; " _ & "INSERT INTO Table1 (AText,ADate) Values ([p1],[p2])" Set qdf = db.CreateQueryDef("", sSQL) qdf.Parameters!p1 = "ABC" qdf.Parameters!p2 = #1/17/2013# qdf.Execute dbFailOnError Debug.Print qdf.RecordsAffected End Sub 
+5
source

Use the more recent version or the latest access database in your links.

For example: Inside the Visual Basics = window Go to Tools> Links> Microsoft Office 14.0. Library of database engine objects .

Then use the following command to open the database:

 Dim database_data As DAO.Database Dim rsData As DAO.Recordset Dim field_index As Integer Set database_data = DAO.OpenDatabase("demo1.accdb") 

Sometimes you may also need to specify the full path to your database file, for example. "C: \ User \ Documents \ Projects \ demo1.accdb"

0
source

All Articles