[AccessD] Question on Reference (DAO)

John W. Colby jwcolby at colbyconsulting.com
Thu Feb 10 14:11:11 CST 2005


John,

What he is saying is that you explicitly reference the lib in the dim
statement.

Dim db as DAO.Database
Dim rst as DAO.Recordset

ADO has a recordset method that returns a recordset object

Dim rst as ADO.Recordset

If you just say 

Dim rst as Recordset

And you have referenced both the ADO and DAO libraries, then the object
returned will be an ADO recordset if that is higher in the list of
referenced objects, and a DAO object if that is higher in the list of
referenced objects.  By specifically stating:

Dim rst as DAO.Recordset

You are unambiguously telling the compiler to get a DAO recordset object.
Likewise:

Dim rst as ADO.Recordset tells the compiler to get an ADO recordset object.

If you reference both the DAO and ADO libs, you always SHOULD specify which
object you are after.  You don't literally have to, but what you get back
will depend on reference order and thus could change if someone changed the
order that the libs are referenced.  NOT a good thing!

John W. Colby
www.ColbyConsulting.com 

Contribute your unused CPU cycles to a good cause:
http://folding.stanford.edu/

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of John Clark
Sent: Thursday, February 10, 2005 2:57 PM
To: accessd at databaseadvisors.com
Subject: RE: [AccessD] Question on Reference (DAO)


Do I reference them via code, or on each PC that runs the program? Or, does
it follow through after I set the reference while programming it?

>>> tom.bolton at donnslaw.co.uk 2/10/2005 3:58 AM >>>
Hear hear!

I've found this too - not having used DAO for years I shied away from it
when returning to an Access project but it's noticeably quicker when using
it for native Access objects.  Access was after all designed around DAO/Jet.

I can't stress enough what Charlotte said: if you use a mixture of DAO and
ADO, REFERENCE THEM EXPLICITLY!  (ADODB.Recordset, DAO.Database etc.) You'll
be in a whole world of pain otherwise.

Cheers
Tom


-----Original Message-----
From: Bobby Heid [mailto:bheid at appdevgrp.com] 
Sent: 09 February 2005 19:27
To: 'Access Developers discussion and problem solving'
Subject: RE: [AccessD] Question on Reference (DAO)

It is my understanding that when accessing native Access databases, that DAO
is the best performer.  If you will be accessing SQL Server or other OLE
databases, use ADO.

Bobby

-----Original Message-----
From: accessd-bounces at databaseadvisors.com 
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of John Clark
Sent: Wednesday, February 09, 2005 1:51 PM
To: accessd at databaseadvisors.com 
Subject: [AccessD] Question on Reference (DAO)


I am working on a new program in A2K. Most of my older existing stuff is
A97, and I just used some old code which had a problem. Basically, I took
some code I was using, from an A97 db, to add items to a combo on
NotInList...I think the code was originally written by Dev Ashish. I got a
"reference" error, so I went into the references and added Microsoft DAO 3.6
object library, and it is working now.

My question is this; is this alright, or should I have adapted the code to
fit 2K? Is there any penalty that I risk (i.e. speed, etc.) by keeping it
this way?

Thanks, 

John W Clark
-- 
AccessD mailing list
AccessD at databaseadvisors.com 
http://databaseadvisors.com/mailman/listinfo/accessd 
Website: http://www.databaseadvisors.com 

-- 
AccessD mailing list
AccessD at databaseadvisors.com 
http://databaseadvisors.com/mailman/listinfo/accessd 
Website: http://www.databaseadvisors.com
-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com






More information about the AccessD mailing list