Thanks Thanks:  0
Likes Likes:  0
Results 1 to 4 of 4

Thread: Error in Database Connection

  1. #1
    Board Regular
    Join Date
    Oct 2009
    Posts
    392
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Error in Database Connection

    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.

  2. #2
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Sydney, Australia
    Posts
    2,940
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Error in Database Connection

    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

  3. #3
    Board Regular
    Join Date
    Oct 2009
    Posts
    392
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Error in Database Connection

    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.

  4. #4
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Sydney, Australia
    Posts
    2,940
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Error in Database Connection

    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

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •