V
Vic Spainhower
Hello,
I have some code in an Access 2002 application to check for missing
references. However, when there is a broken reference I want it to display
the name of the missing module but instead it displays the name of the
adjacent reference. Can someone offer some advice on how to get the correct
name of the missing reference?
Thank you very much!
Vic
Here's the code:
Function VerifyReferences
Dim strMessage As String
Dim strTitle As String
Dim refItem As Access.Reference
Dim iErrors As Integer
Dim iRefCount As Integer
Dim strBadRef As String
Dim strName As String
Dim fsReferences As New FileSystemObject
Dim ShowSecRef As Variant
On Error Resume Next
iErrors = 0
iRefCount = 0
Set fsReferences = CreateObject("Scripting.FileSystemObject")
Set ShowSecRef = fsReferences.CreateTextFile("c:\References.txt", True)
For Each refItem In Application.References
iRefCount = iRefCount + 1
strName = "Reference #" & iRefCount & ": " & refItem.FullPath
' <=== Why isn't this the correct name of the missing module
If refItem.IsBroken Then
ShowSecRef.WriteLine (Date & " " & strName & " is broke")
strBadRef = strName
MsgBox "Broken Reference:" & vbCrLf & strName _
& vbCrLf & vbCrLf & "A critical element of the application is
missing" _
& vbCrLf & "from your computer. Contact support with " _
& vbCrLf & "the missing reference information identified
above.", vbCritical
iErrors = iErrors + 1
Else
ShowSecRef.WriteLine (Date & " " & strName & " is ok")
strMessage = "Reference: " & refItem.Name & vbCrLf _
& "Location: " & refItem.FullPath & vbCrLf _
& "Reference# : " & iRefCount
End If
Next refItem
If iErrors = 0 Then
' Everything is OK
' MsgBox "There are no broken references."
Else
MsgBox "This application has an Invalid Installation and will not
operate properly! " & iErrors & " Unresolved References encountered." &
vbCrLf _
& vbCrLf & "Contact support" & vbCrLf _
& "Missing Module: " & vbCrLf & strBadRef & vbCrLf _
& "There are " & iRefCount & " References." _
& vbCrLf & "Application will terminate ... " _
& vbCrLf & "Consult the chapter on Tech Stuff in the
Installation Prodedure of the documentation."
DoCmd.Quit
End If
Set fsReferences = Nothing
Set ShowSecRef = Nothing
End Function
I have some code in an Access 2002 application to check for missing
references. However, when there is a broken reference I want it to display
the name of the missing module but instead it displays the name of the
adjacent reference. Can someone offer some advice on how to get the correct
name of the missing reference?
Thank you very much!
Vic
Here's the code:
Function VerifyReferences
Dim strMessage As String
Dim strTitle As String
Dim refItem As Access.Reference
Dim iErrors As Integer
Dim iRefCount As Integer
Dim strBadRef As String
Dim strName As String
Dim fsReferences As New FileSystemObject
Dim ShowSecRef As Variant
On Error Resume Next
iErrors = 0
iRefCount = 0
Set fsReferences = CreateObject("Scripting.FileSystemObject")
Set ShowSecRef = fsReferences.CreateTextFile("c:\References.txt", True)
For Each refItem In Application.References
iRefCount = iRefCount + 1
strName = "Reference #" & iRefCount & ": " & refItem.FullPath
' <=== Why isn't this the correct name of the missing module
If refItem.IsBroken Then
ShowSecRef.WriteLine (Date & " " & strName & " is broke")
strBadRef = strName
MsgBox "Broken Reference:" & vbCrLf & strName _
& vbCrLf & vbCrLf & "A critical element of the application is
missing" _
& vbCrLf & "from your computer. Contact support with " _
& vbCrLf & "the missing reference information identified
above.", vbCritical
iErrors = iErrors + 1
Else
ShowSecRef.WriteLine (Date & " " & strName & " is ok")
strMessage = "Reference: " & refItem.Name & vbCrLf _
& "Location: " & refItem.FullPath & vbCrLf _
& "Reference# : " & iRefCount
End If
Next refItem
If iErrors = 0 Then
' Everything is OK
' MsgBox "There are no broken references."
Else
MsgBox "This application has an Invalid Installation and will not
operate properly! " & iErrors & " Unresolved References encountered." &
vbCrLf _
& vbCrLf & "Contact support" & vbCrLf _
& "Missing Module: " & vbCrLf & strBadRef & vbCrLf _
& "There are " & iRefCount & " References." _
& vbCrLf & "Application will terminate ... " _
& vbCrLf & "Consult the chapter on Tech Stuff in the
Installation Prodedure of the documentation."
DoCmd.Quit
End If
Set fsReferences = Nothing
Set ShowSecRef = Nothing
End Function