Hyperlinks

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I have an Input Form which has a Record Source of a look up table. The user
searches by a unique number, which then populates the relevant bound fields.

I want a list of hyperlinks within this table which opens Word Doc. and this
to work on the Form. Is this possible?
 
For those of you wanting to take the hyperlink value from a hyperlink
field in a table you may have some trouble as Access puts a "#" at the
start and end of the link making them not work.

Just remove them:

Private Sub Form_Current()

Me.Label1.HyperlinkAddress = Replace(Me![Hyp], "#", "")

End Sub


If that is still giving you dramas try:

Private Sub Form_Current()

Dim lengthHyp As Integer
Dim hypStr As String
lengthHyp = Len(Me![Hyp]) 'length of the link in the table

hypStr = Left(Me![Hyp], (lengthHyp - 1)) 'trim the "#" of the end
hypStr = Right(hypStr, (lengthHyp - 2)) 'trim the "#" off the
start

Me.Label1.HyperlinkAddress = hypStr

End Sub
 
Alternatively, you could use the built-in HyperlinkPart method! :-)

? HyperlinkPart("#http://www.microsoft.com#", acAddress)
http://www.microsoft.com

--
Brendan Reynolds
Access MVP

JustinP said:
For those of you wanting to take the hyperlink value from a hyperlink
field in a table you may have some trouble as Access puts a "#" at the
start and end of the link making them not work.

Just remove them:

Private Sub Form_Current()

Me.Label1.HyperlinkAddress = Replace(Me![Hyp], "#", "")

End Sub


If that is still giving you dramas try:

Private Sub Form_Current()

Dim lengthHyp As Integer
Dim hypStr As String
lengthHyp = Len(Me![Hyp]) 'length of the link in the table

hypStr = Left(Me![Hyp], (lengthHyp - 1)) 'trim the "#" of the end
hypStr = Right(hypStr, (lengthHyp - 2)) 'trim the "#" off the
start

Me.Label1.HyperlinkAddress = hypStr

End Sub

You can use a hyperlink datatype, or more easily, a simple text field
with
the path to the file, then some code like:

Private Sub Form_Current()
Me.Label1.HyperlinkAddress = "D:\FolderName\" & Me.Text2
End Sub

Which turns a plain label into a hyperlink and allows you to go to
D:\FolderName\ and the file name.
--
Arvin Meyer, MCP, MVP
Free MS-Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
 
Back
Top