Charlotte Foust
cfoust at infostatsystems.com
Tue Aug 8 14:59:01 CDT 2006
Rocky,
The problem with testing references is that a broken reference breaks
the tests. You can't reference the Access object, you have to use
Application like this:
Public Function EnumRefs()
Dim ref As VBIDE.Reference
Dim element As Variant
For Each ref In VBE.ActiveVBProject.References
Debug.Print ref.name, ref.Description, ref.FullPath, ref.BuiltIn
Next ref
Set ref = Nothing
End Function
Charlotte Foust
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Rocky Smolin
- Beach Access Software
Sent: Tuesday, August 08, 2006 12:45 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Removing a missing reference
Marty:
Access.References.Remove refCurr still generates error: -2147319779 -
Object library not registered.
Rocky
MartyConnelly wrote:
> Grr, I am always mixing up Reference and References collection Could
> try disambiguating the code like this
>
> Dim refCurr As Access.Reference
> Dim intCount As Integer
>
>
> For intCount = Access.References.Count To 1 Step -1
> Set refCurr = Access.References(intCount)
> If Not refCurr.BuiltIn Then
> If refCurr.IsBroken Then
> 'might want to check if it has a valid name otherwise skip
> 'or use on error next
> ' debug.print refCurr.name
>
> Access.References.Remove refCurr
> End If
> End If
> Next
>
>
>
> Rocky Smolin - Beach Access Software wrote:
>
>
>> P.S. This reference, when it's there, references a .exe. Don't know
>> if that makes any difference.
>>
>> Rocky
>>
>>
>> Gustav Brock wrote:
>>
>>
>>
>>> 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
>>>
>>>
>>>
>>>
>>>
>>
>>
>>
>
>
--
Rocky Smolin
Beach Access Software
858-259-4334
www.e-z-mrp.com
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com