Microsoft KB Archive/186720

= ACC97: How to Force the IsBroken Property to Return True =

Article ID: 186720

Article Last Modified on 1/23/2007

-

APPLIES TO


 * Microsoft Access 97 Standard Edition

-



This article was previously published under Q186720



SYMPTOMS
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.

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.



RESOLUTION
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.



MORE INFORMATION
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 DLL

To create a broken reference for an ActiveX Control, follow these steps:

 Start Microsoft Access and create a new blank database named DB1.mdb. Create a new report based on any table or query. On the Insert menu, click ActiveX Control. Click "Snapshot Viewer Control, version 8.0," and then click OK. Close the report. Do not save the changes. Close the database.</li> Quit Microsoft Access.</li> Locate the Snapshot Viewer Control file, Snapview.ocx, in the \Windows\System folder (or in the \Winnt\System32 folder if you are using Microsoft Windows NT) and delete the file. Then, empty the Microsoft Windows Recycle Bin.</li> Restart Microsoft Access and open DB1.mdb, which you created in step 1.</li> Create a new module.</li>  Type the following code in the new module: 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 </li> On the Debug menu, click Compile Loaded Modules.</li> Save the Module as CheckIsBroken.</li> Press CTRL+G to open the Debug window.</li>  Type the following in the Debug window, and then press ENTER: ?IsBrokenProperty Note that in the Debug Window you receive one of the following messages, depending on your operating system: <pre class="fixed_text">      Reference broken for: C:\WINDOWS\SYSTEM\SNAPVIEW.OCX

-or-

Reference broken for: C:\WINNT\System32\SNAPVIEW.OCX </li></ol>

NOTE: If you have a reference to another Microsoft Access database and then delete the referred database, you can use a simple IF statement with the IsBroken property and the property will return True.

Additional query words: loop references

Keywords: kbprb kbprogramming KB186720

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.