ACC97: How to Force the IsBroken Property to Return TrueID: Q186720
|
Advanced: Requires expert coding, interoperability, and multiuser skills.
In Microsoft Access, IsBroken is a property of the References collection.
The Microsoft Access Help topic on the Isbroken Property states the
following:
The IsBroken property returns a Boolean value indicating whether a
Reference object points to a valid reference in the Windows Registry.
Although this statement is correct, to receive this Boolean value you must
trap for errors that are generated by the broken reference. Also, the
IsBroken property becomes True only when the file being referenced is
deleted and the Microsoft Windows Recycle Bin is emptied. This article
details the steps necessary to receive the Boolean value.
http://www.microsoft.com/mcsp/For more information about the support options available from Microsoft, please see the following page on the World Wide Web:
http://www.microsoft.com/support/supportnet/overview/overview.asp
If you want to force the IsBroken property to return True, you must first trap the standard error message, and then use the IsBroken property.
To create an example so that IsBroken returns True, you must first create a broken reference. If you create a reference to an ActiveX control or any other library that has its own registry entry and the referenced library is deleted, you will see a standard error message when trying to use the IsBroken property. IsBroken is not able to return True to the Visual Basic for Applications procedure until the standard messages are masked with error trapping. If you do not trap for errors before using IsBroken in the second example, you will receive the following message:
Runtime Error 48: Error in Loading DLLNOTE: A simple way to obtain an ActiveX control that you can use in the following steps is to download and install the Snapshot Viewer, which comes with its own ActiveX control. For information about obtaining the Microsoft Snapshot Viewer, please see the following article in the Microsoft Knowledge Base:
Q175274 ACC97: Microsoft Snapshot Viewer Available on MSL.To create a broken reference for an ActiveX Control, follow these steps:
Public Function IsBrokenProperty()
Dim ref As Reference
' Enumerate through References collection.
For Each ref In References
' Check IsBroken property.
On Error GoTo errorhandler:
If ref.IsBroken = True Then
' Print the name of the reference and the fact that it is
' broken.
Debug.Print ref.Name & " is broken"
End If
Next ref
Exit Function
errorhandler:
' If the error received is 48 it's an error from the broken
' reference. Print the reference the fact it's broken and path to
' the Debug window.
If Err.Number = 48 Then
Debug.Print "Reference broken for: " & ref.FullPath
End If
End Function
?IsBrokenProperty ()
Note that in the Debug Window you receive one of the following
messages, depending on your operating system:
Reference broken for: C:\WINDOWS\SYSTEM\SNAPVIEW.OCX
-or-
Reference broken for: C:\WINNT\System32\SNAPVIEW.OCX
Additional query words: loop references
Keywords : kbdta AccCon PgmHowto
Version : WINDOWS:97
Platform : WINDOWS
Issue type : kbprb
Last Reviewed: July 6, 1999