Option Compare Database
Option Explicit
Function FixUpRefs()
Dim loRef As Access.Reference
Dim intCount As Integer
Dim intX As Integer
Dim blnBroke As Boolean
Dim strPath As String
Dim strVersion As String
On Error Resume Next
'Count the number of references in the database
intCount = Access.References.Count
'Loop through each reference in the database
'and determine if the reference is broken.
'If it is broken, remove the Reference and add it back.
Debug.Print "----------------- References found -----------------------"
Debug.Print " reference count = "; intCount
For intX = intCount To 1 Step -1
Set loRef = Access.References(intX)
With loRef
Debug.Print " reference = "; .FullPath
blnBroke = .IsBroken
If blnBroke = True Or Err <> 0 Then
strPath = .FullPath
Debug.Print " ***** Err = "; Err; " and Broke = "; blnBroke
With Access.References
.Remove loRef
Debug.Print "path name = "; strPath
.AddFromFile strPath
End With
End If
End With
Next
If intCount < 9 Then Call AddRefs ' This one has 9 references
Set loRef = Nothing
' Call a hidden SysCmd to automatically compile/save all modules.
Call SysCmd(504, 16483)
End Function
Function AddRefs()
Dim loRef As Access.Reference
Dim intCount As Integer
Dim intX As Integer
Dim blnBroke As Boolean
Dim strPath As String
On Error Resume Next
'Loop through each reference in the database
'Add all references
Debug.Print "----------------- Add References -----------------------"
If Application.Version = "16.0" Then ' Microsoft Office 2016
With Access.References
.AddFromFile "C:\Program Files\Common Files\System\ado\msadox.dll" 'ADO Ext 6.0
.AddFromFile "C:\Program Files\Common Files\System\ado\msado15.dll" 'Active X Data Objects 6.1
.AddFromFile "C:\Program Files\Microsoft Office\OFFICE16\Excel.exe" 'For Excel Calls
.AddFromFile "C:\Program Files\Common Files\Microsoft Shared\OFFICE16\MSO.dll" 'Microsoft Office Obj Library
.AddFromFile "C:\Program Files\Microsoft Office\OFFICE16\MSOUTL.OLB" 'For Outlook Calls
End With
End If
If Application.Version = "15.0" Then ' Microsoft Office 2013
With Access.References
.AddFromFile "C:\Program Files\Common Files\System\ado\msadox.dll" 'ADO Ext 6.0
.AddFromFile "C:\Program Files\Common Files\System\ado\msado15.dll" 'Active X Data Objects 6.1
.AddFromFile "C:\Program Files\Microsoft Office\OFFICE15\Excel.exe" 'For Excel Calls
.AddFromFile "C:\Program Files\Common Files\Microsoft Shared\OFFICE15\MSO.dll"
.AddFromFile "C:\Program Files\Microsoft Office\OFFICE15\MSOUTL.OLB" 'For Outlook Calls
End With
End If
' Call a hidden SysCmd to automatically compile/save all modules.
Call SysCmd(504, 16483)
End Function
Function WaitFor(NumOfSeconds As Long)
Dim SngSec As Long
SngSec = Timer + NumOfSeconds
Do While Timer < SngSec
DoEvents
Loop
End Function