Class Reference (Access VBA)

The Reference object refers to a reference set to another application's or project's type library. To use a Reference class variable it first needs to be instantiated, for example

BuiltIn

The BuiltIn property returns a Boolean value indicating whether a Reference object points to a default reference that's necessary for Microsoft Access to function properly.

The BuiltIn property is available only by using Visual Basic and is read-only.


Sub ReferenceBuiltInOnly() 
 Dim ref As Reference 
 
 ' Enumerate through References collection. 
 For Each ref In References 
 ' Check BuiltIn property. 
 If ref.BuiltIn = True Then 
 Debug.Print ref.Name 
 End If 
 Next ref 
End Sub

Collection

The Collection property returns a reference to the collection that contains an object.

You can use the Collection property to access the collection to which an object belongs. For example, the Collection property of a Reference object returns an object reference to the References collection. The Collection property is similar to the Parent property.


References(1).Collection

FullPath

The FullPath property returns a string containing the path and file name of the referenced type library.

If the IsBroken property setting of a Reference object is True, reading the FullPath property generates an error.


Sub ReferenceProperties() 
 Dim ref As Reference 
 
 ' Enumerate through References collection. 
 For Each ref In References 
 ' Check IsBroken property. 
 If ref.IsBroken = False Then 
 Debug.Print "Name: ", ref.Name 
 Debug.Print "FullPath: ", ref.FullPath 
 Debug.Print "Version: ", ref.Major & "." & ref.Minor 
 Else 
 Debug.Print "GUIDs of broken references:" 
 Debug.Print ref.GUID 
 EndIf 
 Next ref 
End Sub

Guid

The GUID property of a Reference object returns a GUID that identifies a type library in the Windows Registry.

Every type library has an associated GUID that is stored in the Registry. When you set a reference to a type library, Microsoft Access uses the type library's GUID to identify the type library. You can use the AddFromGUID method to create a Reference object from a type library's GUID.


Sub ReferenceProperties() 
 Dim ref As Reference 
 
 ' Enumerate through References collection. 
 For Each ref In References 
 ' Check IsBroken property. 
 If ref.IsBroken = False Then 
 Debug.Print "Name: ", ref.Name 
 Debug.Print "FullPath: ", ref.FullPath 
 Debug.Print "Version: ", ref.Major & "." & ref.Minor 
 Else 
 Debug.Print "GUIDs of broken references:" 
 Debug.Print ref.GUID 
 EndIf 
 Next ref 
End Sub

IsBroken

The IsBroken property returns a Boolean value indicating whether a Reference object points to a valid reference in the Windows Registry.

The default value of the IsBroken property is False. The IsBroken property returns True only if the Reference object no longer points to a valid reference in the Registry. By evaluating the IsBroken property, you can determine whether the file associated with a particular Reference object has been moved to a different directory or deleted. If the IsBroken property is True, Microsoft Access generates an error when you try to read the Name or FullPath properties.


Sub ReferenceProperties() 
 Dim ref As Reference 
 
 ' Enumerate through References collection. 
 For Each ref In References 
 ' Check IsBroken property. 
 If ref.IsBroken = False Then 
 Debug.Print "Name: ", ref.Name 
 Debug.Print "FullPath: ", ref.FullPath 
 Debug.Print "Version: ", ref.Major & "." & ref.Minor 
 Else 
 Debug.Print "GUIDs of broken references:" 
 Debug.Print ref.GUID 
 EndIf 
 Next ref 
End Sub

Kind

The Kind property indicates the type of reference that a Reference object represents.

The Kind property returns the following values.


References(1).Kind

Major

The Major property of a Reference object returns a read-only Long value indicating the major version number of an application to which you have set a reference.

The Major property returns the value to the left of the decimal point in a version number. For example, if you've set a reference to an application whose version number is 2.5, the Major property returns 2.


Dim r As Reference 
Dim strInfo As String 
 
For Each r In Application.References 
 strInfo = strInfo & r.Name & " " & r.Major & "." & r.Minor & vbCrLf 
Next 
 
 
MsgBox "Current References: " & vbCrLf & strInfo

Minor

The Minor property of a Reference object returns a Long value indicating the minor version number of the application to which you have set a reference.

The Minor property returns the value to the right of the decimal point in a version number. For example, if you've set a reference to an application whose version number is 2.5, the Minor property returns 5.


Dim r As Reference 
Dim strInfo As String 
 
For Each r In Application.References 
 strInfo = strInfo & r.Name & " " & r.Major & "." & r.Minor & vbCrLf 
Next 
 
 
MsgBox "Current References: " & vbCrLf & strInfo

Name

You can use the Name property to determine the string expression that identifies the name of an object.

A valid name must conform to the standard naming conventions for Microsoft Access. For Access objects, the name may be up to 64 characters long. For controls, the name may be as long as 255 characters. The default name for new objects is the object name plus a unique integer. For example, the first new form is Form1, the second new form is Form2, and so on. A form can't have the same name as another system object, such as the Screen object. For an unbound control, the default name is the type of control plus a unique integer. For example, if the first control that you add to a form is a text box, its Name property setting is Text1. For a bound control, the default name is the name of the field in the underlying source of data. If you create a control by dragging a field from the field list, the field's FieldName property setting is copied to the control's Name property box. You can't use "Form" or "Report" to name a control or section. Controls on the same form, report, or data access page can't have the same name, but controls on different forms, reports, or data access pages can have the same name. A control and a section on the same form can't share the same name.


References(1).Name