vbams-accessreportms-access-reports

Add hyperlink to textbox in Access Report


I have an access report that I am populating a textbox on the report from VBA code. I am in need of a way to add a hyperlink to certain text in the textbox so that it will read like the below, so that only one word in the textbox is a hyperlink

This is text in textbox.  We are filled with random facts about fun stuff, 
and great <hyperlink>things</hyperlink>!!!

Solution

  • You have the tags vba and access-vba so I can provide a VBA solution for you. If you add a text box to your report, and set the name to textbox1 and open the properties and change the Text Format = Rich Text then you can use HTML in the VBA to code a hyperlink.

    Now with that being done open the VBE and in whatever event (button click, page load etc) - add this syntax

    Dim url as String
    url = "http://www.google.com"
    
    Me.textbox1.SetFocus
    Me.txtbox1.Text = "Text here for whatever now let's add the hyperlink " & _
                      "<a href = " & url & ">Hyperlink Text</a>!!!."
    

    Now when you view the report in Report View the site you put in for the variable url will be a hyperlink from the text above Hyperlink Text