Share via

GoHyperlink() - Help needed

Anonymous
2018-08-04T17:10:13+00:00

I have followed the instructions on Allen Browne's site for GoHyperlink() below.

I then created a form that contains a text box (Text0) bound to a field in a table that contains a hyperlink to a PDF document. Also on the form is a Command Button (Command2) control that has an On Click event procedure that leads to a Private Sub:

Private Sub Command2_Click()

Call GoHyperlink(Me.[Text0])

End Sub

But when I click on the Command Button, I get an error as follows:

"The expression On Click you entered as the event property produced the following error: Object or class does not support the set of events."

I would appreciate advice on what I'm doing wrong. I'm using MS Access 2003.

Using GoHyperlink()

To use GoHyperlink() in your database:

  1. Create a new stand-alone module in your database. Open the code window (Ctrl+G), and the New Module button on the toolbar (2nd from left on Standard toolbar.)
  2. Paste in the code below.
  3. To verify Access understands it, choose Compile on the Debug menu.
  4. Save the module, with a name such as ajbHyperlink.

You can now use GoHyperlink() anywhere in your database.

For example if you have a form with a hyperlink field named MyHyperlink,

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

9 answers

Sort by: Most helpful
  1. Anonymous
    2018-08-05T11:25:02+00:00

    Access 2003 should certainly support the call to the Windows API function.  I'm not sure when the FollowHyperlink method was introduced.

    What happens if you call something innocuous in the button's Click event procedure? e.g.

        MsgBox "Hello World"

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2018-08-05T09:39:05+00:00

    Ken,

    Thanks for your reply to my question.

    I looked at your BrowseDemo example and still experienced the same problem when using it with Access 2003.

    "The expression On Click you entered as the event property produced the following error: Object or class does not support the set of events."

    But when I used it with Access365 it worked fine and opened a PDF file. I tried adding the path using the Browse function and also by linking it to the table with the filepath (having converted it to text rather than hyperlink). Both worked.

    So it seems there is a problem with Access 2003 - does it perhaps not support the function?

    Thanks again for your help.

    Also thanks to Tom and Gina for responding on this.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2018-08-04T20:48:47+00:00

    If you set up the field in the Table as a Hyperlink Data Type, try removing the Hyperlink Data Type.

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2018-08-04T20:02:30+00:00

    If you are storing the link in a column of hyperlink data type I would advise against doing so.  It's more trouble than it's worth in my experience.  Instead store the full path to the PDF file in a column of short text data type.  You can then either call the FollowHyperlink method of the Application object as Tom suggests, or the Windows API ShellExecute function.  The latter has the advantage that it can also print a file of appropriate type.  You might like to take a look at BrowseDemo.zip in my public databases folder at:

    https://onedrive.live.com/?cid=44CC60D7FEA42912&id=44CC60D7FEA42912!169

    Note that if you are using an earlier version of Access you might find that the colour of some form objects such as buttons shows incorrectly and you will need to  amend the form design accordingly.  

    If you have difficulty opening the link, copy the link (NB, not the link location) and paste it into your browser's address bar.

    This little demo file illustrates how to return the path to a file by browsing to it, with the option of then opening or printing the file by means of the ShellExecute function.  In the demo the form is unbound, but the same methodology can be used to assign a value to a control bound to a column in a table of course.

    The form also illustrates how to format a control containing a text value as a hyperlink, which can then be clicked on in the usual way.

    Was this answer helpful?

    0 comments No comments
  5. Tom van Stiphout 40,211 Reputation points MVP Volunteer Moderator
    2018-08-04T18:12:46+00:00

    Forget all that code, and use the built-in Application.FollowHyperlink.

    Was this answer helpful?

    0 comments No comments