It is very difficult to accurately and reliably detect reference
problems. And very few people would even attempt to automatically
fix a reference problem if one was detected. Unfortunately, a
problem with one reference may cause total failure of the application.
A reasonably robust method is to, BEFORE USING ANY REFERENCE OR LIBRARY
CODE AT ALL, very carefully check that all the references are in the
expected locations, and are the correct versions (you can't do a good
version check for mdb/mde, but you can for activeX controls). If
the check fails, notify the user that the referenced files need to
be in the correct locations. Obviously, you can't totally avoid
using the VBA and the Access reference, which is a weakness of
all these methods.
If you don't need or can't use that method, then a reasonable
approach would be to try to detect a reference failure, delete
the reference, shut down, on restart detect the missing reference,
try to add it, shut down, and restart. You have to do the
checking and testing immediately on start-up, avoid using ANY reference
or library code, and shut down immediately afterwards, to get
reasonably good reliability.
The KB article that you reference shows how to use a query to
try to check if you have broken references, without causing a
total application crash. Unfortunately, that method still does
sometimes cause a total application crash. The article also
includes a loop through the reference collection that you can
use to TRY to identify a broken reference. The query check
works because ANY broken reference may call ALL referenced code
to fail.
In the KB article the reference checking loop also shows how
to delete and add a reference. Unfortunately, the loop does
not always identify broken references (which is why it was not
used for the reference check), but it will identify totally
missing files.
I would break it down into smaller items for the testing and
repairing, to try to make it a little more reliable, but the
code as shown does seem to at least attempt to address the
problem you are having. You should try to use it, and if you
have problems, come back here with specific questions.
(david)