Error 7980: HyperlinkAddress or HyperlinkSubAddress read-only for Hyperlink

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32633

    Error 7980: HyperlinkAddress or HyperlinkSubAddress read-only for Hyperlink

    Error 7980: The HyperlinkAddres s or HyperlinkSubAdd ress property is read-only for this hyperlink

    I'm struggling with some code to update Hyperlinks in my table. The field is defined as a Hyperlink and is editable without problem from the interface (I open the table for display, right-click on an item and select Hyperlink / Edit Hyperlink and all is fine).

    The table is defined very simply as :
    Table = tblLink
    Code:
    [I]Field   Type        Index[/I]
    LinkID  Autonumber  PK
    Link    Hyperlink
    I run into problems however, when I try to update (or even add a new one from scratch) this item on my form. The form is laid out as :
    Form = tblLinkEdit
    Code:
    [I]Control         Type    Bound[/I]
    txtLinkID       TextBox   Y
    txtDescription  TextBox
    txtHTTP         TextBox
    txtLink         TextBox   Y
    The operator fills in both of the unbound TextBoxes, then the code should create a Hyperlink in txtLink from what's entered.

    The code for the update (AfterUpdate of both of the unbound TextBoxes) is as follows (txtLink is designed as locked so no-one tries to edit it in place) :
    Code:
    Private Sub txtDescription_AfterUpdate()
        Call UpdateLink
    End Sub
    
    Private Sub txtHTTP_AfterUpdate()
        Call UpdateLink
    End Sub
    
    Private Sub UpdateLink()
        With Me.txtLink
            .Locked = False
            .Value = Me.txtDescription
            .Hyperlink.Address = Me.txtHTTP
            .Locked = True
        End With
    End Sub
    I've tried various other ways of approaching this problem but as none of them has shown any success, I won't bore you with the details. Suffice to say I tried editing the existing Hyperlink as well as attempting to build it from scratch as in this code.

    When it gets to line #13 the error message of the title pops up :
    Error 7980: The HyperlinkAddres s or HyperlinkSubAdd ress property is read-only for this hyperlink

    NB. I find it particularly confusing as the property I'm attempting to assign is neither of those of course.

    I'd be grateful for any sort of assistance. If anyone can simply point me to where to look that would be fine.
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32633

    #2
    Although this particular problem is still confusing me, I did eventually find (by looking differently) something that helped me to do what I needed without accessing the .Hyperlink property directly.

    The page I found (Introduction to Hyperlink fields) was from Allen Browne's site. The concept is simply to set the .Value of the TextBox to a three way string comprising Description#Link#Sublink (Sublink optional).

    My final code is :
    Code:
    Private Sub UpdateLink()
        With Me
            .txtLink.Locked = False
            '+ used with strings resolves to Null if any element is Null.
            Select Case "" + .txtDescription + .txtHTTP
            Case Null
                .txtLink = .txtDescription & .txtHTTP
            Case Else
                .txtLink = .txtDescription & "#" & Me.txtHTTP & "#"
            End Select
            .txtLink.Locked = True
        End With
    End Sub
    The best part of it all is - It works!

    Comment

    Working...