Share via

Hyperlink Property [Access 2003 VBA Language Reference]

You can use the Hyperlink property to return a reference to a Hyperlink object. You can use the Hyperlink property to access the properties and methods of a Hyperlink object associated with a command button, image, or label control. Read-only.


expression Required. An expression that returns one of the objects in the Applies To list.


The Hyperlink property is available only by using Visual Basic .


The CreateHyperlink procedure in the following example sets the hyperlink properties for a command button, label, or image control to the address and subaddress values passed to the procedure. The address setting is an optional argument, because a hyperlink to an object in the current database uses only the subaddress setting, To try this example, create a form with two text box controls (txtAddress and txtSubAddress) and a command button (cmdFollowLink) and paste the following into the Declarations section of the form's module:

Private Sub cmdFollowLink_Click()
    CreateHyperlink Me!cmdFollowLink, Me!txtSubAddress, _
End Sub

Sub CreateHyperlink(ctlSelected As Control, _
     strSubAddress As String, Optional strAddress As String)
    Dim hlk As Hyperlink
    Select Case ctlSelected.ControlType
        Case acLabel, acImage, acCommandButton
            Set hlk = ctlSelected.Hyperlink
            With hlk
                If Not IsMissing(strAddress) Then
                    .Address = strAddress
                    .Address = ""
                End If
                .SubAddress = strSubAddress
                .Address = ""
                .SubAddress = ""
            End With
        Case Else
            MsgBox "The control '" & ctlSelected.Name _
                 & "' does not support hyperlinks."
    End Select
End Sub

Applies to | ComboBox Object | CommandButton Object | Control Object | Image Object | Label Object | ListBox Object | TextBox Object

See Also | AddToFavorites Method | Follow Method | FollowHyperlink Method | HyperlinkAddress Property | HyperlinkPart Method | HyperlinkSubAddress Property