Broken References

M

Matthew Hood

I'm working on an Access application that uses Word, Excel, and MapPoint
automation. This application will be distrubuted onto a multitude of
systems. Some systems will have Office installed, others will not. (On the
systems without Office, the Access 2002 Runtime will be installed).

The original programmers referenced the Type Libraries to create all their
routines instead of using the "CreateObject" method.
Unfortunately these object references are used all over the place and we do
not have the time to convert our code.

So what I'm running into is when our application get's installed onto a
system without Word, Excel, and MapPoint, when the user opens the database,
they get a Broken References error, and then the database quits.

I need help in finding a way to handle this situation. I need to be able to
either remove the references on startup (and add them back i in when Word,
Excel, and MapPoint get installed), or supress the error message. (Which I
don't think will work because Access won't find any other functions in other
Libraries due to the missing ones)

Any help is greatly appreciated.
TIA,
Matt
 
V

Van T. Dinh

If you use late-binding, you don't need to add the Word / Excel / MapPoint
Object Library in the References Collection of your database. The Libraries
still have to be there for the codes to work. Also, you may need to modify
the codes since the original developers may use symbolic constants from
other Libraries.

Check Access VB Help / your Access VBA books on early-binding vs
late-binding.
 
T

Tony Toews

Matthew Hood said:
I'm working on an Access application that uses Word, Excel, and MapPoint
automation. This application will be distrubuted onto a multitude of
systems. Some systems will have Office installed, others will not. (On the
systems without Office, the Access 2002 Runtime will be installed).

The original programmers referenced the Type Libraries to create all their
routines instead of using the "CreateObject" method.
Unfortunately these object references are used all over the place and we do
not have the time to convert our code.
So what I'm running into is when our application get's installed onto a
system without Word, Excel, and MapPoint, when the user opens the database,
they get a Broken References error, and then the database quits.

I need help in finding a way to handle this situation. I need to be able to
either remove the references on startup (and add them back i in when Word,
Excel, and MapPoint get installed), or supress the error message. (Which I
don't think will work because Access won't find any other functions in other
Libraries due to the missing ones)

This depends on whether you ship an MDE or MDB. If an MDE you don't
have a choice. You can't programmatically alter the references. You
must use Late Binding. You will have to make the time to fix up your
code.

Great opportunity to beat up on the original programmers. And blame
them for all the sins.<smile>

If an MDB then you can programmatically update the references.
However wield things might start happening in places. Such as Left$,
Mid$ and Trim$ in queries no longer working.

Standard blurb follows.

Late binding means you can safely remove the reference and only have
an error when the app executes lines of code in question. Rather than
erroring out while starting up the app and not allowing the users in
the app at all. Or when hitting a mid, left or trim function call.

You'll want to install the reference if you are programming or
debugging and want to use the object intellisense while in the VBA
editor. Then,. once your app is running smoothly, remove the
reference and setup the late binding statements.

Sample code:
' Declare an object variable to hold the object
' reference. Dim as Object causes late binding.
Dim objWordDoc As Object
Set objWordDoc = CreateObject(" Word.Document")

For more information including additional text and some detailed links
see the "Late Binding in Microsoft Access" page at
http://www.granite.ab.ca/access/latebinding.htm

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
 
M

Matthew Hood

Thanks for the help!
I guess I'm going to have to spend the weekend coverting to late-bound code.
The late binding brings up another question...

With MapPoint, I have to test for an object type of MapPoint.Pushpin.
Is there a way to accomplish this with late binding?

ie: *** pOldSelection can be several different object types... and is passed
through a MapPoint Event.
Private Sub MapPointControl_SelectionChange(ByVal pNewSelection As Object,
ByVal pOldSelection As Object)
Dim oLoc as Object

If (Not pOldSelection is Nothing) Then
If (TypeOf pOldSelection Is MapPoint.Pushpin) Then
Set oLoc = pOldSelection.Location
End If
End If

End Sub

Thanks again for the help.
-Matt
 
V

Van T. Dinh

This is likely to be a symbolic constant I mentioned in my earlier post.
The chance is that it is a numeric value and you simply replace symbolic
constant with its numeric value.

I don't use MapPoint but an example in Access is acTextBox = 109.
 
T

Tony Toews

Matthew Hood said:
Thanks for the help!
I guess I'm going to have to spend the weekend coverting to late-bound code.
The late binding brings up another question...

Sorry for Van and I to be the bearer of bad news.
If (TypeOf pOldSelection Is MapPoint.Pushpin) Then

If that isn't a constant then try searching at groups.google.com or
asking in the mappoint newsgroup. There are several MVPs there who
are quite code aware and knowledgable.

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
 
M

Matthew Hood

Thanks again Van and Tony for all the help.
I had to come up with a workaround for my MapPoint issue. (Just tested for a
known property/method and used the generated error to determine what type of
object I had.)

Thanks again.
-Matt
 

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