+ Reply to Thread
Results 1 to 19 of 19

DAO importing doesn't work

  1. #1
    Forum Contributor
    Join Date
    06-19-2013
    Location
    UK
    MS-Off Ver
    Excel 2016
    Posts
    144

    DAO importing doesn't work

    Hello, I'm trying to get a macro in Excel to import table from Access.

    I have this working fully in ADO, but when I try DAO I keep getting a runtime error at the open database part and cannot see why.

    Please Login or Register  to view this content.

  2. #2
    Registered User
    Join Date
    11-23-2012
    Location
    London, England
    MS-Off Ver
    Excel 2007/10
    Posts
    18

    Re: DAO importing doesn't work

    do you have the dao library reference selected?

    Also just try

    Please Login or Register  to view this content.
    otherwise what is the runtime error you are getting?
    Last edited by alansidman; 11-12-2015 at 08:54 PM. Reason: Code tags added: Please read rules

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: DAO importing doesn't work

    What's the error message?
    If posting code please use code tags, see here.

  4. #4
    Forum Contributor
    Join Date
    06-19-2013
    Location
    UK
    MS-Off Ver
    Excel 2016
    Posts
    144

    Re: DAO importing doesn't work

    I have ticked 'Microsoft DAO 3.6 Object Library'

    I don't get a message, it just shows an error box
    error.png

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: DAO importing doesn't work

    Which line of code gives you that error?

    Where is the code located?

    What level do you have error trapping set to under Tools>Options...?

  6. #6
    Forum Contributor
    Join Date
    06-19-2013
    Location
    UK
    MS-Off Ver
    Excel 2016
    Posts
    144

    Re: DAO importing doesn't work

    It fails at the OpenDatabase line.

    Please Login or Register  to view this content.
    I haven't touched the error trapping, so it's on the default 'Break on Unhandled Errors'

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: DAO importing doesn't work

    Try changing the level of error trapping to either Break on all Errors or Break in Class modules.

    That won't help fix the code but it might help with debugging it.

  8. #8
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: DAO importing doesn't work

    Are you running 64-bit?

  9. #9
    Forum Contributor
    Join Date
    06-19-2013
    Location
    UK
    MS-Off Ver
    Excel 2016
    Posts
    144

    Re: DAO importing doesn't work

    Windows 7 is 64 bit. Office is 32 bit

    I changed to break on all errors.

    I get a runtime error 3343. Unrecognised database format.
    Why do I get this, it's just a standard Access database?

  10. #10
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: DAO importing doesn't work

    I don't think you can't use DAO with an accdb database.

  11. #11
    Forum Contributor
    Join Date
    06-19-2013
    Location
    UK
    MS-Off Ver
    Excel 2016
    Posts
    144

    Re: DAO importing doesn't work

    How odd. Everywhere I went to online said to use the Microsoft DAO 3.6 Object Library.

    After a quick google of that new error message I've now changed the reference to 'Microsoft Office 14.0 Access database engine Object Library' and it now works. Thank you

  12. #12
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: DAO importing doesn't work

    Why do you want to use DAO if you've got it working in ADO?

  13. #13
    Forum Contributor
    Join Date
    06-19-2013
    Location
    UK
    MS-Off Ver
    Excel 2016
    Posts
    144

    Re: DAO importing doesn't work

    I'm learning.
    My macro also takes quite a while so I was also curious to know if there were any speed differences so I could pick the fastest one.

  14. #14
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: DAO importing doesn't work

    Not looping a range to populate it will improve the performance far more than trying to swap ADO for DAO

  15. #15
    Forum Contributor
    Join Date
    06-19-2013
    Location
    UK
    MS-Off Ver
    Excel 2016
    Posts
    144

    Re: DAO importing doesn't work

    I don't know what you mean sorry ?

    Are you saying to use CopyFromRecordset, I haven't done that because I'm using functions per imported value.
    Last edited by Smally; 11-13-2015 at 10:20 AM.

  16. #16
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: DAO importing doesn't work

    Yes, why can't you just use conditional formatting?

    Looping through a worksheet is very, very slow and should be kept to a minimum, especially if you have a lot of data. If you want an intermediate step, you could use GetRows and manipulate the data in an array - then write that to the sheet in a single pass

  17. #17
    Forum Contributor
    Join Date
    06-19-2013
    Location
    UK
    MS-Off Ver
    Excel 2016
    Posts
    144

    Re: DAO importing doesn't work

    This is my function that colours the cells:
    Please Login or Register  to view this content.
    Out of the 2 tables that I import, the first table contains the values (mostly dates), the other table contains true or false, each have their own colour code system.
    I don't think doing this is possible via conditional formatting.

  18. #18
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: DAO importing doesn't work

    Why don't you just do a join?

  19. #19
    Forum Contributor
    Join Date
    06-19-2013
    Location
    UK
    MS-Off Ver
    Excel 2016
    Posts
    144

    Re: DAO importing doesn't work

    My excel file is stored on a public folder where many employees can view it.
    I have made my Access DB to use various make table queries onto another Access DB that is also stored on the the public folder. The excel file imports from the DB in the public folder.

    I'm still learning about access so I don't know how get my make table queries onto another DB that include joins.

    And to actually get the data setup ready for the make table queries requires several other select and crosstab queries.
    There very well may be a better way compared to what I've got going, but I don't know, and it's taken me months to get to this stage.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] F4 doesn't work only in excel, how to make it work again?
    By Dave H in forum Excel General
    Replies: 1
    Last Post: 02-26-2014, 11:22 AM
  2. [SOLVED] Macro work in personal workbook, doesn't work in other workbooks
    By Centexcel in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-30-2013, 11:47 AM
  3. [SOLVED] Macro Doesn't Work Through Button, Does Work Through Developer ->Macros Option
    By freybe06 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 06-27-2013, 11:55 AM
  4. [SOLVED] DocumentBeforeSave and Print doesn't work after importing external data
    By Marco-Kun in forum Word Programming / VBA / Macros
    Replies: 7
    Last Post: 07-31-2012, 07:55 PM
  5. F 5 doesn't work right.
    By mrl in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-12-2010, 11:04 AM
  6. Why doesn't this work !!
    By Anthony in forum Excel General
    Replies: 1
    Last Post: 10-08-2005, 09:05 AM
  7. Why doesn't this work in Win 2K?
    By Ken Loomis in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-14-2005, 06:05 AM
  8. [SOLVED] Anyone know why this doesn't work
    By BT in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-28-2005, 05:05 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1