When I installed an Access 2003 database on another computer, I had 2 broken references on the other computer. I can easily fix the references manually, but I need to do it at runtime because I will be installing the database--and the runtime version of Access--on several computers that either do not have Access or have an earlier version of Access (i.e., 97 or 2000).
I did find code that detects and fixes broken references at http://support.microsoft.com/kb/194374/en-us
. However, Access cannot get the fullPath (or any other properties) of my broken references--which means it cannot fix them. When I click on the misiisng references in the References list, Access displays the pathnames of these DLL files. I cannot figure out why Access cannot get the properties of these missing references. Any ideas?
Here is my code and the resulting debug messages form hte debug.print statements I added.
-------------------- CODE ---------------
'See if any references (to program code libraries) are broken.
'If a reference is broken, remove it and add it again. This
'will fix the problem that occurs when the the computer that created
'the program and the computer the program was installed upon have
'different versions of a code library.
On Error Resume Next
Dim loRef As Access.Reference
Dim intCount As Integer
Dim intX As Integer
Dim fBroke As Boolean
Dim strPath As String
'Count the number of references in the database
intCount = Access.References.Count
'Loop through all of the references.
'For each reference:
' - see if it is broken
' - if the reference is broken, then
' - remove it and
' - add it back in
For intX = intCount To 1 Step -1
Set loRef = Access.References(intX)
Debug.Print "Reference(" & intX & "):" _
& "FullPath = " & .FullPath & vbCrLf _
& " Name = " & .Name & ", IsBroken = " & .IsBroken
fBroke = .IsBroken
If fBroke = True Or Err <> 0 Then
Debug.Print intX & " is broken, Error " & Err.Number & ": " & Err.Description
strPath = .FullPath
Set loRef = Nothing
'Call a hidden SysCmd to automatically compile and save all modules
Call SysCmd(504, 16483)
------------------------- DEBUG LOG ------------------
Reference(7):FullPath = C:\WINNT\system32\stdole2.
Name = stdole, IsBroken = False
Reference(6):FullPath = C:\Program Files\Common Files\Microsoft Shared\OFFICE11\MSO.DLL
Name = Office, IsBroken = False
Reference(5):FullPath = C:\Program Files\Common Files\Microsoft Shared\DAO\dao360.dll
Name = DAO, IsBroken = False
4 is broken, Error -2147319779: Method 'FullPath' of object 'Reference' failed
3 is broken, Error -2147319779: Method 'FullPath' of object 'Reference' failed
Reference(2):FullPath = C:\Program Files\Microsoft Office\OFFICE11\MSACC.OLB
Name = Access, IsBroken = False
Reference(1):FullPath = C:\Program Files\Common Files\Microsoft Shared\VBA\VBA6\VBE6.DLL
Name = VBA, IsBroken = False