The DAO that can be spoken of is not the DAO

S

Stapes

Hi

If I state in my VB:

Dim blah DAO.Database, does that make it a DAO Database, or is it DAO
anyway?

Stapes
 
R

Rick Brandt

Stapes said:
Hi

If I state in my VB:

Dim blah DAO.Database, does that make it a DAO Database, or is it DAO
anyway?

Stapes

As far as I know DAO is the only library that has a Database object so you
don't need the prefix. Those that use the prefixes often just prefer to use
them everywhere for the sake of clarity and/or consistency.
 
N

Norman Yuan

I am not very sure what you really want to know. Here is my answer to yuor
question literally:

Dim blah As DAO.Database

means:

You want VB to create a variable, which is a pointer/reference, in the
memory, in order to refer to an object stored in memory somewhere later. In
this case, this pointer/reference can only be used to point/refer to a
DAO.Database object, nothing else. However "Dim" the variable, does not
create/make anything, it just sits in memory and points/referes to nowhere,
meaning it is "Nothing" at this point of time, and it is cleared out from
memory when out of scope, whether the real object it pointed to is still
alife or not.
 
G

George Nicholson

The ADO and DAO object libraries share some object names, (Recordsets being
the 100 lb elephant), so its important to specify which type you want in
those cases (aka, disambiguate the reference). Since the Database object
only appears in DAO, I guess it's a matter of personal habit/consistency to
explicitly declare *any* member of ADO/DAO libraries as such, rather than
just the objects that 'need' to be. IMHO, it helps to keep things straight
in my mind as the code is being written *or maintained*.

In other words, *if* you have a reference to the DAO object librbary set,
then "Dim rs as Database" would automatically refer to a DAO database
*unless* you also had a reference to some other object library that also
included a Database object (and I have no idea what that would be). Without
a DAO object library reference, that declaration would generate a compile
error. (Exception: I believe DAO is "built into" Access 2007, so it doesn't
require a separate reference.)


HTH,
 
Top