Recordsetclone

Q

Question Boy

Is it improper to use DAO with RecordsetClone?

For example:

Dim rs as DAO.Recordset
Set rs = .RecordsetClone

Or should it be

Dim rs as Recordset
Set rs = .RecordsetClone

Is there a difference?

Thank you,

QB
 
D

Douglas J. Steele

It's proper to use DAO.Recordset. Whether or not ignoring the DAO. matters
depends on the references in your application. Recordset is an object in
both the ADO and DAO models. If you only have a reference set to DAO, then
the two declarations are equivalent. If you have references set to both,
then which recordset object you get using Dim rs As Recordset depends on
which reference is higher in the list. If ADO is higher (which, by default,
it is in Access 2003), the non-disambiguated declaration will result in rs
being an ADO recordset. If DAO is higher, then the two declarations will be
equivalent.
 
M

Marshall Barton

Question said:
Is it improper to use DAO with RecordsetClone?

For example:

Dim rs as DAO.Recordset
Set rs = .RecordsetClone

Or should it be

Dim rs as Recordset
Set rs = .RecordsetClone

Is there a difference?


Disambiguating your declarations is a good thing, but it is
essential when you have multiple libraries containing
objects, properties, methods and VBA variables with the same
names. Since you can not predict what libraries you might
need in the future, it is a good practice to do it right
from the start.

Your example of declaring a recordset object could use
either the DAO or ADO or ??? libraries, it would be safer to
use DAO.Recordset.
 
D

Dale Fye

non-disambiguated ???

What dictionary can I find that in? ;-)

--
HTH
Dale

email address is invalid
Please reply to newsgroup only.
 
D

Dale Fye

Damn, Marsh,

You used it too? Is that a term that only shows up in the MVP dictionary?

--
Dale

email address is invalid
Please reply to newsgroup only.
 
D

Dymondjack

Dale, I clicked your name at the top of the post (I was curious... I'll
admit), and was going to sent you an email.

You give your email as:

email:Dale dot Fye at cox dot net
remove spaces and replace dot with .

So i tried sending an email to Dale.Fyeatcox.net

but it wouldn't go. Any ideas???
 
D

Dale Fye

I quess it wasn't obvious to replace at with @
--
HTH
Dale

email address is invalid
Please reply to newsgroup only.
 
M

Marshall Barton

Dale said:
Damn, Marsh,

You used it too? Is that a term that only shows up in the MVP dictionary?


No. It's in my copy of Webster's Collegiate:

"to establish a single semantic
or grammatical interpretation"

Without looking it up, I would have said that it simply
means to remove ambiguity.

It is a common thing to do in object orientated programming
so it's time to include it in your thought processes ;-)
 
D

David W. Fenton

Is it improper to use DAO with RecordsetClone?

For example:

Dim rs as DAO.Recordset
Set rs = .RecordsetClone

Or should it be

Dim rs as Recordset
Set rs = .RecordsetClone

Is there a difference?

Why would you ever bother with that? I see a lot of people posting
navigation code like this:

Dim rs As DAO.Recordset

Set rs = Me.RecordsetClone
rs.FindFirst "[criteria]"
If rs.NoMatch Then
MsgBox "Not Found!"
Else
Me.Bookmark = rs.Bookmark
End If
Set rs = Nothing

It's far, far easier to do this:

With Me.RecordsetClone
.FindFirst "[criteria]"
If .NoMatch Then
MsgBox "Not Found!"
Else
Me.Bookmark = .Bookmark
End If
End With

The RecordsetClone already exists. There is no reason not to use it
directly and avoid the entire question of initializing and cleaning
up a recordset variable.

As to your question, it's always important to disambiguate variable
types. Given that ADO has a Recordset object just like DAO, but
which is completely incompatible, it's wise to disambiguate in all
cases.

If you did only:

Dim rs As Recordset

and ADO was first in the references list, then you'd get an error
when you tried to assign the RecordsetClone to it, as the
RecordsetClone is always a DAO recordset. You'd get a type mismatch.

But, as I said, there's no reason you should ever even need to do
this with a RecordsetClone.

In all other cases, disambiguating produces better, more
maintainable code.
 
D

David W. Fenton

You give your email as:

email:Dale dot Fye at cox dot net
remove spaces and replace dot with .

So i tried sending an email to

What kind of moron posts a persons unmunged email address in a
Usenet post? Do you understand the purpose of munging an email
address?
 
D

Dymondjack

It was an attempt at humor, following Mr. Fye's attempt at humor.

My apologies, if it was misunderstood.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top