Access 2007 – Setting a default hyperlink

I have a project in Access 2007 with hyperlink fields.  What I really needed to do was create a default link to a specific directory – at which point the end user can drill further down into a sub directory and select a specific Word file.

Well – seems to be a bit of a problem – spent some time searching and found requests and questions on how to do this, but not a lot of answers.

So – based on suggestions from here, here and  Allen Browne’s Introduction to Hyperlink Fields page I was able to come up with a VBA function:

Private Function SetHTMLLink(ByRef myControl As TextBox)
  If IsNull(myControl.Value) Then
    myControl.Value = “#\\<hyperlink to source>”
  End If
End Function

What is going on is MS Office Hyperlink fields – this is not limited to Access, Excel uses the same algorithm it seems – works like this:

display text # file name (the hyperlink) # a reference within the file

Okay – so MS parses based on the pound (#) character and passes three parameters to some built-in function.  Which can then be assigned to the Value of the Hyperlink control.  It works – and that is all that matters.


About Lee Greffin
Just another programmer...

One Response to Access 2007 – Setting a default hyperlink

  1. eldaveo says:

    Been having a lot of trouble with this. Thanks!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: