[AccessD] Question on Reference (DAO)

Charlotte Foust cfoust at infostatsystems.com
Fri Feb 11 12:10:51 CST 2005


No, because the objects in the two models are different, and there's no
such thing as an ADODB.Database.  If you intend to use ADO, you have to
become familiar with its objects and syntax and keep it quite distinct
in your mind (and your code) from DAO.

Charlotte Foust


-----Original Message-----
From: John Clark [mailto:John.Clark at niagaracounty.com] 
Sent: Friday, February 11, 2005 5:03 AM
To: accessd at databaseadvisors.com
Subject: RE: [AccessD] Question on Reference (DAO)


So, where I already had:

Dim db As DAO.Database
Dim rs As DAO.Recordset

I would put:

Dim db As ADODB.Database
Dim rs As ADODB.Recordset

?????

It is working now, because I went into Tools/References and clicked on
the, "Microsoft DAO 3.6 Reference Library." I was just wondering if this
would follow through to the client PC.


>>> cfoust at infostatsystems.com 2/10/2005 4:20 PM >>>
The only correction I'll suggest to that, John, is that the reference is
to an ADODB.Recordset, etc.

Charlotte Foust


-----Original Message-----
From: John W. Colby [mailto:jwcolby at colbyconsulting.com] 
Sent: Thursday, February 10, 2005 12:11 PM
To: 'Access Developers discussion and problem solving'
Subject: RE: [AccessD] Question on Reference (DAO)


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 



-- 
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