late binding?

Z

Zlatko Matiæ

I was reading about late binding, but I'm not completely sure what is to be
done in order to adjust code to late binding...
For example, I'm not sure if this is correct:

early binding:

Dim ws As DAO.Workspace
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim rs As DAO.Recordset


late binding:
Dim ws as Object
Set ws =CreateObject("DAO.Workspace")
Dim ws as Object
Set db =CreateObject("DAO.Database")
Dim qdf as Object
Set qdf =CreateObject("DAO.QueryDef")
Dim rs as Object
Set rs =CreateObject("DAO.Recordset")

VBA help says that class argument inside Create object function has to be in
appname.objecttype format. Does it means that "DAO" should be preceded by
"Access", so the previous code should be like this:

Dim ws as Object
Set ws =CreateObject("Access.DAO.Workspace")
Dim ws as Object
Set db =CreateObject("Access.DAO.Database")
Dim qdf as Object
Set qdf =CreateObject("Access.DAO.QueryDef")
Dim rs as Object
Set rs =CreateObject("Access.DAO.Recordset")
?
What exactly I need to change in my code in order to support "late binding"
?
All examples given in VBA help and internet are concerning late binding in
case of calling other Office aplication from Access, but I couldn't find
examples of late binding inside Access itself...so I'm little bit confused.
Is there any Add-in or program, that can change early binding declarations
to late binding declarations through all modules automaticcally ?


Zlatko
 
D

Douglas J Steele

DAO.Workspace (and the other DAO.xxx) is sufficient. DAO isn't actually part
of Access: it's a separate library.

Odds are you aren't going to need anything other than

Set ws =CreateObject("DAO.Workspace")

though.

Assuming you're trying to open a database in the workspace you just
instantiated, you'll be using

Set db = ws.OpenDatabase(...)
Set qdf = db.CreateQueryDef(...)
Set rs = qdf.OpenRecordset(...)

and so on.

The other issue is removing all use of intrinsic constants. You either need
to define the constants yourself, or else replace them with the numeric
value. Remove the reference, compile your application and find them all! (I
assume you have Option Explicit defined!)

I'm not aware of any add-in that can do the conversion for you.

Hopefully, though, your example is hypothetical. AFAIK, you must have a
reference to DAO or ADO for your application to work.
 
Z

Zlatko Matiæ

OK., Doug, thanks for explaination...
I think I get it now...

Greetings,

Zlatko
 
T

Tony Toews

Zlatko Matiæ said:
Dim ws As DAO.Workspace

I'm not at all sure why you'd want to use Late Binding for DAO.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
 
Z

Zlatko Matic

In fact, I haven't experienced troubles with DAO references, but ADO
(msado15.dll), so maybe I should reformulate my question to ADO late
binding. Anyway, I just need some solution for my .mde to assure that it
will work on any Office version, at least from Office 2000.
While you can mannually refresh references in .mdb, it is not possile in
..mde, so it is always possible that my distributed .mde will not work on
client computer...
What is the alternative to late binding ? How can I distribute .mde and be
sure that it will work on any Office version ?

Greetings,

Zlatko
 
R

Rick Brandt

Zlatko said:
In fact, I haven't experienced troubles with DAO references, but ADO
(msado15.dll), so maybe I should reformulate my question to ADO late
binding. Anyway, I just need some solution for my .mde to assure that
it will work on any Office version, at least from Office 2000.
While you can mannually refresh references in .mdb, it is not possile
in .mde, so it is always possible that my distributed .mde will not
work on client computer...
What is the alternative to late binding ? How can I distribute .mde
and be sure that it will work on any Office version ?

If you need to work with multiple versions of Office then there is no
(practical) alternative to late binding.
 
Z

Zlatko Matiæ

I would appreciate some practical example that includes typical DAO
(workspace, database, QueryDef, recordset) and ADO objects (connection,
command, recordset...).
In fact, I successfully implemented late binding for some ADO recordsets,
but was unsuccessfull with DAO...
I use both DAO and ADO in my code...

Zlatko
 
T

Tony Toews

Zlatko Matic said:
In fact, I haven't experienced troubles with DAO references, but ADO
(msado15.dll), so maybe I should reformulate my question to ADO late
binding. Anyway, I just need some solution for my .mde to assure that it
will work on any Office version, at least from Office 2000.
While you can mannually refresh references in .mdb, it is not possile in
.mde, so it is always possible that my distributed .mde will not work on
client computer...
What is the alternative to late binding ? How can I distribute .mde and be
sure that it will work on any Office version ?

I have limited experience with Late Binding when it comes to DAO.
What I needed to do did work fine in Jet 4.0 and Jet 3.5. Hmm, I
think it did work in Jet 2.0 as well but I sure could be mistaken.

But I have no experience as far as ADO goes as I've hardly ever used
ADO.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
 

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