Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there an automated way to load references using VBA?

Status
Not open for further replies.

hazlehurstga

Programmer
Sep 4, 2003
19
0
0
US
Does anyone know of an automated way to verify and load references using VBA coding?
Thanks
 
Do a search on the Forum looking for references since there have been many threads on this topic. Also, Microsoft has examples on their site. I will paste in a function that I call from the AutoExec macro that may work for you or at least point you in the right direction.


Function FixUpRefs()
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

'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 &quot; ***** Err = &quot;; Err; &quot; and Broke = &quot;; blnBroke
With Access.References
.Remove loRef
Debug.Print &quot;path name = &quot;; strPath
.AddFromFile strPath
End With
End If
End With
Next
'''Access.References.AddFromFile &quot;C:\Program Files\Common Files\Microsoft Shared\DAO\dao360.dll&quot;

Set loRef = Nothing

' Call a hidden SysCmd to automatically compile/save all modules.
Call SysCmd(504, 16483)
End Function

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top