ACC2000: How to Loop Through References to View Their Properties
ID: Q209849
|
The information in this article applies to:
Moderate: Requires basic macro, coding, and interoperability skills.
This article applies to a Microsoft Access database (.mdb) and a Microsoft Access project (.adp).
SUMMARY
When you view the location of references with the References dialog
box on the Tools menu, 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, 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
MORE INFORMATION
To loop through the References collection and retrieve the properties of each reference, follow these steps:
- Create a module and type the following line in the Declarations
section if it is not already there:
Option Explicit
- Type the following procedure:
Function ReferenceInfo()
Dim strMessage As String
Dim strTitle As String
Dim refItem As Reference
On Error Resume Next
For Each refItem In References
If IsError(refItem.Name) Then
strMessage = "Missing Reference:" & vbCrLf & refItem.FullPath
Else
strMessage = "Reference: " & refItem.Name & vbCrLf _
& "Location: " & refItem.FullPath & vbCrLf
End If
Debug.Print strMessage
Next refItem
End Function
- To test this function, type the following line in the Immediate window, and then press ENTER:
? ReferenceInfo
Note that each reference is listed in the Immediate window.
REFERENCES
For more information about the References collection, in the Visual Basic Editor, click
Microsoft Visual Basic Help on the Help menu, type "reference object" in
the Office Assistant or the Answer Wizard, and then click Search to
view the topic.
For more information about enumerating through the References collection by
using the For Each...Next statement, in the Visual Basic Editor, click
Microsoft Visual Basic Help on the Help menu, type "next" in
the Office Assistant or the Answer Wizard, and then click Search to
view the topic.
For additional information about getting help with Visual Basic for Applications, please see the following article in the Microsoft Knowledge Base:
Q226118 OFF2000: Programming Resources for Visual Basic for Applications
Additional query words:
reference
Keywords : kbdta AccCon PgmHowto KbVBA
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbhowto