Error in Database Connection

kashif.special2005

Active Member
Joined
Oct 26, 2009
Messages
443
Hi,

While, I am using Sub (fetch_data) to fetch data from Access database and paste into excel file but error message is showing that
Erro Message:- Run-time error '3343';
Unrecognized database format 'C:\Users\Kashif\Desktop\Access Database & File\Kashif.accdb'.

Code.

Public db As DAO.Database
Public dbpath As String
Public rs As DAO.Recordset


Public Sub connection()
On erro GoTo err:
'dbpath = ActiveWorkbook.Path + "\" + Sheets("criteria").Cells(2, 6)

dbpath = Sheets("criteria").Cells(4, 6)
'Full path is C:\Users\Kashif\Desktop\Access Database & File\Kashif.accdb
Set db = OpenDatabase(dbpath, ture, True)
Exit Sub
err:
Select Case err.Number
Case 3024
MsgBox "Database not found. Please save the database at the location of current folder"
Application.Calculation = xlCalculationAutomatic
End
Case Else
End Select
End Sub


Public Sub fetch_data()
Dim sql As String
Call connection
sql = "select * from Allocation"
Set rs = db.OpenRecordset(sql, dbOpenSnapshot)
Sheets("criteria").Cells(5, 1).CopyFromRecordset rs
rs.Close

End Sub

Please help.

Thanks,
Kashif.
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Hi

Which version of DAO do you have referenced? If you go into Tools, References from within the VB editor the file referenced should be named acedao.dll as that it what is required to connect to accdb files.

HTH
DK
 
Upvote 0
Hi,

I am using Microsoft DAO 3.6 Object Library, but I am not able to find acedao.dll in Tolls>References.

Please guide me, That how can I add that reference in my workbook.

Thanks,
Kashif.
 
Upvote 0
Do you have Office 2007 or 2010 installed? On my installation of Office 2010 the file is located in C:\Program Files (x86)\Common Files\Microsoft Shared\OFFICE14\ACEDAO.DLL

I did notice that they have changed the naming style of the file description (which is what you see in the Tools, References dialog). Under the pre-accdb rules (DAO 3.6 and earlier) they used to be named things like Microsoft DAO 3.51 Object Library but the new one is Microsoft Access database engine Data Access Object

HTH
DK
 
Upvote 0

Forum statistics

Threads
1,214,537
Messages
6,120,096
Members
448,944
Latest member
SarahSomethingExcel100

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top