DAO to ADO

  • Thread starter Thread starter ag
  • Start date Start date
A

ag

I switched libraries from DAO to ADO.
Code unrelated to ADO that has executed properly for years
suddenly generates an error. Particularly when trying to
execute a DoCmd.
Errors are not always systematic.
Any helpfull suggestion will be appreciated.
Thanks.
 
The two libraries are not interchangeable. Although they
use similar terminology the syntax and behaviour are
different.

Unless you want to rewrite your code to use ADO which could
be a very great deal of work, then reset your reference to
DAO. If you don't also remove the reference to ADO you will
have to alter your code to 'disambiguate' it (MS's term).

Dim rst as Recordset
becomes
Dim rst As DAO.Recordset
and so on

This is because there are a number of terms common between
the two libraries.

The reason that you're getting errors which appear to be
un-systematic is because the code is no longer delivering
the right bits of data at the expected time. Where the code
might expect a recordset to present some data for
concatenation into a string for use in a SQL command there
may be nothing there.
 
Thanks for your comments Nick.
The problem I have is that I did remove the DAO library
reference and I replaced it with the ADO library. Then I
changed relevant code to eliminate any compile error. I
still have to use DoCmd and macros for other purposes.
Is it that the recompile does not replace all the hidden
DAO code?
Thanks again.
 
Recompiling doesn't change code for you, you have to do that
by hand.

DoCmd and macros should still work fine they're nothing to
do with ADO or DAO.

The reason you're getting problems is because you've not
altered your code to use ADO correctly - I mean, although
you don't get compile errors, it's now buggy.

Problem now is fault finding/debugging it and rewriting code
to correct.

Personally I'd restore a backup and reinstate the DAO
reference because that will be a lot less work. Unless of
course you have to use ADO for some reason, in which case
you'll have to set 'break on all errors' and plough through
your code bit by bit trying to isolate the part(s) where you
have problems to recode.
 
Access 2000 will sometimes not replace all hidden
code: you should /decompile or import all objects
into a new database to be sure of that.

But when you get 'unrelated' errors that are 'not
always systematic', it indicates a reference problem.
Check your other references, and make sure that
all references (including ADO) are correctly installed.

(david)
 
Thanks Nick.
I will probably reinstate the DAO version of my Access DB.
I find it intriguing though.
I moved all my objects to a new DB referencing ADO instead
of DAO. I never get an error executing ADO code. In the DB
I am working on now, I execute a docmd.openreport right
after closing an ADO recordset. Sometimes it works,
sometimes it bombs. There must be some incompatibility
there. In another DB, a similar problem occurs but not all
the time.
Thanks again.
 
Back
Top