How do I create dyanmic hyperlinks in an Access report?

M

Maurice Snell

I want to take data values from query fields or expressions and use them to
generate URLs, e.g.
"http://somewhere.com/Products/" & [ProductName]
but all the hyperlink objects only seem to accept a static string, not a
dynamic expression.

Any suggestions, apart from writing raw html for the entire report including
headers & formatting?
 
M

Maurice Snell

The problems are that:
- Hyperlink object does not accept expressions in address or caption field -
only absolute strings
- There's no way to make a query calculated field have the data type of
Hyperlink: I've tried putting in "#" etc.

So in the end I had to write VB code to set the HyperlinkAddress property of
a Hyperlink object in my report, (URL_Hyperlink), using live values from
other query fields, ([ManualURL]). Pretty horrible, but it does work:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Not IsNull([ManualURL]) Then
URL_Hyperlink.HyperlinkAddress = [ManualURL]
URL_Hyperlink.Caption = [ManualURL]
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top