Connecting Tech Pros Worldwide Help | Site Map

Error 7980: HyperlinkAddress or HyperlinkSubAddress read-only for Hyperlink

NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,672
#1: Oct 10 '09
Error 7980: The HyperlinkAddress or HyperlinkSubAddress 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
Expand|Select|Wrap|Line Numbers
  1. Field   Type        Index
  2. LinkID  Autonumber  PK
  3. 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
Expand|Select|Wrap|Line Numbers
  1. Control         Type    Bound
  2. txtLinkID       TextBox   Y
  3. txtDescription  TextBox
  4. txtHTTP         TextBox
  5. 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) :
Expand|Select|Wrap|Line Numbers
  1. Private Sub txtDescription_AfterUpdate()
  2.     Call UpdateLink
  3. End Sub
  4.  
  5. Private Sub txtHTTP_AfterUpdate()
  6.     Call UpdateLink
  7. End Sub
  8.  
  9. Private Sub UpdateLink()
  10.     With Me.txtLink
  11.         .Locked = False
  12.         .Value = Me.txtDescription
  13.         .Hyperlink.Address = Me.txtHTTP
  14.         .Locked = True
  15.     End With
  16. 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 HyperlinkAddress or HyperlinkSubAddress 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.
best answer - posted by NeoPa
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 :
Expand|Select|Wrap|Line Numbers
  1. Private Sub UpdateLink()
  2.     With Me
  3.         .txtLink.Locked = False
  4.         '+ used with strings resolves to Null if any element is Null.
  5.         Select Case "" + .txtDescription + .txtHTTP
  6.         Case Null
  7.             .txtLink = .txtDescription & .txtHTTP
  8.         Case Else
  9.             .txtLink = .txtDescription & "#" & Me.txtHTTP & "#"
  10.         End Select
  11.         .txtLink.Locked = True
  12.     End With
  13. End Sub
The best part of it all is - It works!
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,672
#2: Oct 10 '09

re: Error 7980: HyperlinkAddress or HyperlinkSubAddress read-only for Hyperlink


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 :
Expand|Select|Wrap|Line Numbers
  1. Private Sub UpdateLink()
  2.     With Me
  3.         .txtLink.Locked = False
  4.         '+ used with strings resolves to Null if any element is Null.
  5.         Select Case "" + .txtDescription + .txtHTTP
  6.         Case Null
  7.             .txtLink = .txtDescription & .txtHTTP
  8.         Case Else
  9.             .txtLink = .txtDescription & "#" & Me.txtHTTP & "#"
  10.         End Select
  11.         .txtLink.Locked = True
  12.     End With
  13. End Sub
The best part of it all is - It works!
Reply

Tags
control, edit, hyperlink, read-only, textbox, vba