Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

early/late binding confusion 1

Status
Not open for further replies.

Eupher

MIS
Jul 18, 2002
1,724
US
I'm working on some code to send calendar items to Groupwise from my Access XP database. According to the Groupwise API, early binding is preferable in almost all cases. As nearly as I can tell, here's how the API says to declare a Groupwise application object using early binding:

Code:
Dim objGWApp As Application3
Set objGWApp = New Application3

However, this code bombs with the message "ActiveX control cannot create the object".

Late binding works, though:

Code:
Dim objGWApp As Object
Set objGWApp = CreateObject("NovellGroupwareSession")

But this ALSO works:

Code:
Dim objGWApp As Application3
Set objGWApp = CreateObject("NovellGroupwareSession")

Using the third option ACTS like early binding, because the Intellisense works when entering methods and such, but I'd like to be sure. Can anyone shed any light on this? Thanks!

Ken S.
 
Early Binding is when you declare the object variable specifically to the type that it is to represent. This will also require that the appropriate references be included into the project.

Dim objGWApp As NovellGroupwareSession
Set objGWApp = New NovellGroupwareSession

In Late Binding, the object type is not known until the object is created as a specific type, usually by the CreateObject function, or the Set statement.

Dim objGWApp As Object
Set objGWApp = CreateObject("NovellGroupwareSession")

Intellisense will only work is the type of object is known. In the first case, the Dim statement defines the type of object directly, so Intellisense will work with the NovellGroupwareSession object. In the second case, the object is generic until execution, so intellisense doesn't know the object type, therefore cannot help with associated properties and methods.

In your third example:
Dim objGWApp As Application3
Set objGWApp = CreateObject("NovellGroupwareSession")
Intellisense is operation under the assumption that its the object type Application3, so the provided hints are associated with an Application3 object type. But, that object is being late bound to the NovellGroupwareSession object type, with the binding occurring at the time the CreateObject function is executed.

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
CajunCenturion, thanks for the explanation. I was afraid that was what my third option was doing, but I wasn't sure.

In any event, my syntax in the first option was essentially correct, but for some reason (even though the API said to use the latest version numbers), the code wouldn't work with the Application3 type - even though Application3 appears in the Intellisense list of object types. I changed it to Application2 and it worked fine. Odd, since I'm using Access XP on an XP box, with the latest version of Groupwise. Go figure.

Thanks again!

Ken S.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top