ACC97: How to Force the IsBroken Property to Return True

ID: Q186720


The information in this article applies to:


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, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals 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 needs. If you have limited programming experience, you may want to contact a Microsoft Certified Solution Provider or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Solution Providers, please see the following page on the World Wide Web:

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


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
NOTE: 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:

  1. Start Microsoft Access and create a new blank database named DB1.mdb.


  2. Create a new report based on any table or query.


  3. On the Insert menu, click ActiveX Control.


  4. Click "Snapshot Viewer Control, version 8.0," and then click OK.


  5. Close the report. Do not save the changes.


  6. Close the database.


  7. Quit Microsoft Access.


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


  9. Restart Microsoft Access and open DB1.mdb, which you created in step 1.


  10. Create a new module.


  11. Type the following code in the new module:


  12. 
            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 
  13. On the Debug menu, click Compile Loaded Modules.


  14. Save the Module as CheckIsBroken.


  15. Press CTRL+G to open the Debug window.


  16. 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:


  17. 
           Reference broken for: C:\WINDOWS\SYSTEM\SNAPVIEW.OCX
    
            -or-
    
           Reference broken for: C:\WINNT\System32\SNAPVIEW.OCX 
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          : kbdta AccCon PgmHowto 
Version           : WINDOWS:97
Platform          : WINDOWS 
Issue type        : kbprb 

Last Reviewed: July 6, 1999