Remove missing reference by vba

U

Ulrich1947

Hi to all !

Is there any way of removing a missing reference by vba ?

I use routine on starting access, to find out whether a reference is broken
or not which reads

For allgKZnum1 = 1 To Zähler
If References(allgKZnum1).IsBroken = True Then
xxx
Else
End If
Next allgKZnum1

Not knowing, which reference might be broken I want to remove that broken
reference. From a separate table I can refer from the broken reference (by
its GUID) to the references name. I have tried to put this name in a variable
actRef and then use

References.Remove References(actRef)

But this does not work at all. Or can't I remove missing References not at
all by vba?

Any idea?

Thanks

Ulrich
 
A

Allen Browne

No. That's not possible.

As soon as VBA realizes there is a broken reference, you're shot. Testing
the IsBroken property guarantees that VBA knows the reference is bad, so as
soon as you get one that returns True, your code will not work past that
point, so you can't fix it.

The only chance you get is before Access knows the reference is broken. It
won't know this if there is no call to the broken library. You can delay the
time when Access calls the broken library if your initialization code
disambiguates everything. For example, use VBA.Left() instead of Left().

michka has more info in this article:
How to guarantee that references will work in your applications
at:
http://www.trigeminal.com/usenet/usenet026.asp?1033

In practice, the real solution is to avoid any references that are not
absolutely essential. Most things can be done in Access instead of with
external libraries, so most Access applications can manage with just the 3
core ones: Access, VBA, and DAO.
 
U

Ulrich1947

Thanks for anwering. It helped not to search further (which is a great help)
but actually did not lead me to a solution.

However, do you know by any chance, whether this problem is handled in
Access 2007 (of which I run the beta version), resp. whether it is seen as a
problem at microsoft worth to be solved?

Thanks again

Ulrich
 
A

Allen Browne

I see no reason why it would be different in A2007.

Apart from the "trusted location" stuff in the new version, the VBA IDE
operates the same way.
 

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