# VB Hyperlink code in Access 2003



## bdrafts (Mar 19, 2006)

I am looking for some VB code to create a relative hyperlink in my Access 2003 database. I know about 'hyperlinkaddress', but can not get it to work with each entry in my table. Here is an example:

Field data Desired Hyperlink address
alldata.pdf /mydir/alldata.pdf
myform.pdf /mydir/myform.pdf
ectetc.pdf /mydir/ectetc/pdf

I simply want to append /mydir/ in the hyperlink address and eliminate the Access appended 'http://". I know VB code will do this, but I am having issues using it.
Also, I have already tried using the Database Properties - Hyperlink base - it does not work for HTML formated reports.

Thanks!


----------



## OBP (Mar 8, 2005)

Is that whole thing supposed to be an address or many addresses?
Why are using a hyperlink address to look at a pdf document you should be using an OLE object.
Once you set the table's field property to an OLE Object you can then go to the pdf document click on it, "copy" and then "paste" it in the table's field.
Double clicking the field will then open the pdf document with whatever pdf reader you have.


----------



## cristobal03 (Aug 5, 2005)

I'm confused, is this a local file or an Internet file you're trying to link? You can use a *hyperlink label* to open a local file (or an Internet file) via Access, which is what it sounds like you're trying to do. Here's some sample code.


```
Private Sub lblSomeLabelControl_Click()
  Dim strLinkUrl  As String
  Dim strPath     As String

  ' for a subdirectory located in the same directory
  ' as the database:
  strPath = Access.Application.CurrentProject.Path & "\My Subdirectory\"

  strLinkUrl = strPath & "somefile.pdf"

  Me.lblSomeLabelControl.HyperlinkAddress = strLinkUrl
End Sub
```
That's airware.

chris.


----------



## bdrafts (Mar 19, 2006)

Thank you.


----------



## bdrafts (Mar 19, 2006)

Thank you very much.


----------



## cristobal03 (Aug 5, 2005)

Hi, did this solve your issue? If so, you can mark this thread "Solved" using the *Thread Tools* at the top of the page.

chris.


----------

