ACC97: How to Loop Through References to View Their Properties (186305)



The information in this article applies to:

  • Microsoft Access 97

This article was previously published under Q186305
Moderate: Requires basic macro, coding, and interoperability skills.

SUMMARY

When you view the location of references with the Tools References dialog box, the trailing portion of the path name may be truncated because of the limitations of the dialog box. This article shows you how to use a Visual Basic for Applications procedure to loop through the References collection and retrieve the properties of each reference.

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.

MORE INFORMATION

To loop through the References collection and retrieve the properties of each reference, follow these steps:

  1. Create a module and type the following line in the Declarations section if it is not already there:
    Option Explicit
    					
  2. Type the following procedure:
        Sub ReferenceInfo()
          Dim strMessage As String
          Dim strTitle As String
          Dim bytButtons As Byte
          Dim refItem As Reference
    
          On Error Resume Next
    
          For Each refItem In References
             If refItem.IsBroken Then
                strTitle = "MISSING Reference"
                strMessage = "Missing Reference:" & vbCrLf & refItem.FullPath
                bytButtons = 16 'critical symbol
             Else
                strTitle = "Displaying References and Their Locations"
                strMessage = "Reference: " & refItem.Name & vbCrLf & _
                "Location: " & refItem.FullPath
                bytButtons = 64 'information symbol
            End If
    
          MsgBox prompt:=strMessage, Title:=strTitle, buttons:=bytButtons
    
          Next refItem
    
        End Sub
    					
  3. To test this function, type the following line in the Debug window, and then press ENTER:
    ReferenceInfo
    						
    Note that the message box opens for each reference.

REFERENCES

For more information about the References collection, search the Help Index for "References Collection," or ask the Microsoft Access 97 Office Assistant.

For more information about enumerating through the References collection by using the For Each...Next statement, search the Help Index for "For Next," select "For Each...Next statement", click Display and click "Using For Each... Next Statements" from the Topics Found dialog box.

For more information about getting help with Visual Basic for Applications, please see the following article in the Microsoft Knowledge Base:

163435 VBA: Programming Resources for Visual Basic for Applications


Modification Type:MinorLast Reviewed:10/11/2006
Keywords:kbhowto kbProgramming KB186305