DAO vs ADO

  • Thread starter Thread starter Josh
  • Start date Start date
J

Josh

When compiling my Access 2002 frontend, I am suddenly
getting an error message for:

Dim db as database

I notice that there is no database type variable in the
list I pull up. I am guessing this is an ADO, DAO
conflict, and the app is old and therefore DAO. The code
had been working fine for a few years. I'm in trouble if I
have to go back and find every place this syntax is used.

1) what is preferable syntax?
2) where did "database" go? (and why?)

Thanks so much!!
Josh
 
Database is a DAO object. There's not really an equivalent in ADO.

To be able to use DAO in Access 2000 or newer, open any code module, select
Tools | References from the menu bar, scroll through the list of available
references until you find the one for Microsoft DAO 3.6 Object Library, and
select it. If you're not going to be using ADO, uncheck the reference to
Microsoft ActiveX Data Objects 2.1 Library

If you have both references, you'll find that you'll need to "disambiguate"
certain declarations, because objects with the same names exist in the 2
models. For example, to ensure that you get a DAO recordset, you'll need to
use Dim rsCurr as DAO.Recordset (to guarantee an ADO recordset, you'd use
Dim rsCurr As ADODB.Recordset)

The list of objects with the same names in the 2 models is Connection,
Error, Errors, Field, Fields, Parameter, Parameters, Property, Properties
and Recordset
 
When compiling my Access 2002 frontend, I am suddenly
getting an error message for:

Dim db as database

I notice that there is no database type variable in the
list I pull up. I am guessing this is an ADO, DAO
conflict, and the app is old and therefore DAO. The code
had been working fine for a few years. I'm in trouble if I
have to go back and find every place this syntax is used.

1) what is preferable syntax?
2) where did "database" go? (and why?)

It sounds as though you are experiencing a "references" issue that won't require
rewriting anything. See the following page at Doug Steele's web site for
information on fixing this:

http://members.rogers.com/douglas.j.steele/AccessReferenceErrors.html
 
An addendum to Douglas' response: disambiguating (nice word!) the references
isn't nearly as gruesome as it might first appear. Simply do a series of
Finds on "As Object" and Replaces with "As DAO.Object", replacing Object
with the object names that occur in both DAO and ADO, per his list (plus
Database, for code clarity if no either reason).

Long term, I think you would be better off taking 5 minutes and disambiguate
references now rather than simply removing the default ADO object library
reference and *assuming* it will stay removed in the future. But maybe
that's just me.
 
Back
Top