How can I change the Hyperlink Address Property from Read-Only to allow updates?

I am trying, for the first time, to use the Hyperlink option for a textbox to open a PDF file and I get a read-only run-time error when running my code.

The field in the table is of Data Type "Hyperlink".

The textbox properties:

IsHyperlink = "No"  ( I have also tried setting this to "YES")

Display as Hyperlink = "If Hyperlink"

Hyperlink Target = C"\My Path\   ( I have also tried leaving this blank)

When I manually perform a Hyperlink Edit on the textbox, it works as it should.  However I am trying to use VBA to create the Hyperlink Address using the following code that I've found in researching Hyperlinks in general:

        With Forms("CashChargeTransaction").Controls("ReceiptAddress").Hyperlink
            .Address = "C:\Users\Walt\Documents\Warranty Receipts\Distributor.pdf"
        End With

The result is a run-time error '7980': The HyperlinkAddress or HyperlinkSubAddress property is read-only for this hyperlink.

I don't know, and haven't been able to locate information as to where the HyperlinkAddress property is or how to change it. 

Suggestions/direction will be muchly appreciated.

I am trying, for the first time, to use the Hyperlink option for a textbox to open a PDF file and I get a read-only run-time error when running my code.

The field in the table is of Data Type "Hyperlink".

The textbox properties:

IsHyperlink = "No"  ( I have also tried setting this to "YES")

Display as Hyperlink = "If Hyperlink"

Hyperlink Target = C"\My Path\   ( I have also tried leaving this blank)

When I manually perform a Hyperlink Edit on the textbox, it works as it should.  However I am trying to use VBA to create the Hyperlink Address using the following code that I've found in researching Hyperlinks in general:

        With Forms("CashChargeTransaction").Controls("ReceiptAddress").Hyperlink
            .Address = "C:\Users\Walt\Documents\Warranty Receipts\Distributor.pdf"
        End With

The result is a run-time error '7980': The HyperlinkAddress or HyperlinkSubAddress property is read-only for this hyperlink.

I don't know, and haven't been able to locate information as to where the HyperlinkAddress property is or how to change it. 

Suggestions/direction will be muchly appreciated.

More info:

This must not be a common question, as I have not been able to find the answer.  Very frustrating for what I perceive should be a simple task.

I have researched my 2010 Bible, Access 2010 VBA Macro Programming, and just about any topic combination in the Help files that I can think of.  I found an MS Article written for VB 3.0, but it was very confusing and seems to address changing the Read-Only Property for the whole database as opposed to a single textbox.  Have also found a reference to the read-only property, which said to go to the File menu under Database Options, but that isn't in my drop down list.  Also found the same question posted in UtterAccess in October of 2004, but there was no response or suggestion for that user.  Have also gone to the MS Developer Network and tried the example with a new form and text boxes, but it wouldn't work at all.

I've also tried the following line of code in my database and got the same error message:

ReceiptAddress.Hyperlink.Address = "C:\Users\Walt\Documents\WarrantyReceipts\Distributor.pdf"

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

It appears as though changing the Read-only property of a textbox Hyperlink Address just isn't possible.  Therefore a work around is necessary which I developed using a suggestion from Michael S. Meyers-Jouan in another forum.

For anyone else who might want or need to accomplish the process of automating a hyperlink, here is what I did - it's really quite simple and best of all, it works:

1- In my table I created a field as a Hyperlink Data Type named ReceiptAddress

2- In my form, I created three text boxes:

     One with a Control Source set to a field named, "Item"

     One with a Control Source set to the ReceiptAddress field

     One with an Unbound Control Source, Textbox named, "ScannedFileName"

3. In the MyDocuments folder I have a sub folder named "Warranty Receipts" and the scanned document file is saved in that folder.

4. After scanning the receipt, the filename, "ReceiptFileName.PDF" is entered in the ScannedFileName Textbox of my form.

   Note that the filename consists of both the name and suffix, “.PDF”

5.  In the On Click event of a Save Record Button I created a string variable named, "Path" and assigned a value of:

     Path = "#C:\MyPath\Warranty Receipts\". 

     Note the start and end quotes and "#" as the first character and "\" as the last character of the Path.

5. The same procedure, the ReceiptAddress field is populated by the line:

        ReceiptAddress = Item & Path & ScannedFileName which results in:

            Item#Path\ScannedFileName

6. On my main form, I have a textbox named, “ShowReceipt”, which is bound to the “ReceiptAddress” field in the table and displays only the Item with the underline indicating it is a hyperlink.  Clicking on this textbox displays the receipt.

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated December 9, 2022 Views 96 Applies to: