[AccessD] Removing a missing reference

Gustav Brock Gustav at cactus.dk
Tue Aug 8 13:12:58 CDT 2006


Hi Rocky

Further to Charlotte's comments, I faintly recall you have to move backwards in the References collection:

Public Function ReferencesClean() As Boolean

' Remove all missing references.
' Return True if no reference was removed.
'
' 2001-08-20. Cactus Data ApS, CPH.

  Dim ref         As Reference
  Dim lngItem     As Long
  Dim booMissing  As Boolean
  
  With References
    For lngItem = .Count To 1 Step -1
      Set ref = .Item(lngItem)
      If ref.BuiltIn = True Then
        ' No need to check built in reference.
      ElseIf IsBroken97(ref) Then
        .Remove ref
        booMissing = True
      End If
    Next
  End With
  
  Set ref = Nothing
  
  ReferencesClean = Not booMissing
  
End Function

Still, your code will be left non-compiled after this. A method to compile the code is described by Charlotte and me if you search the archives of July 2003 for:
"Broken References in Runtime AXP and A97"

/gustav

>>> bchacc at san.rr.com 08-08-2006 19:46:07 >>>
Dear List:

Still struggling with this references thing.  It seem the easiest thing 
to do would be to remove the missing reference in the Open event of the 
opening form in the event the app is loaded onto a machine which doesn't 
have the library.  However, all the code that I've seen to remove 
missing references fail.  Code like:

Dim refCurr As Reference
    For Each refCurr In References
        If refCurr.IsBroken Then
            References.Remove refCurr
        End If
    Next

Seems straightforward but when it comes to the missing reference it 
errors out on the .Remove line because it doesn't have a name.  So.  How 
do you remove a missing reference when the application the reference is 
referring to doesn't exist?

MTIA

Rocky




More information about the AccessD mailing list