Hyperlink on form

B

blake7

Hi I would like to add a hyperlink to my form inside a text box, i would like
the users to click in the box and choose 'add hyperlink' from the menu bar,
but i cannot get it to work in form view, i can add a hyperlink in design
view but i do not want the user to go into design view, any ideas. Thank You
 
A

Arvin Meyer [MVP]

blake7 said:
Hi I would like to add a hyperlink to my form inside a text box, i would
like
the users to click in the box and choose 'add hyperlink' from the menu
bar,
but i cannot get it to work in form view, i can add a hyperlink in design
view but i do not want the user to go into design view, any ideas. Thank
You

Instead of using the hyperlink datatype, try using plain text instead. A URL
or file can be connected from a textbox by using code, like:

Sub cmdHyperlink_Click()
Dim strPath As String
If Not IsNull(Me.txtBoxName) Then
strPath = Me.txtBoxName
Me.cmdHyperlink.HyperlinkAddress = strPath
End If
End Sub

where cmdHyperlink is a command button. Double-clicking on the textbox would
work as well.:

Sub txtBoxName_DblClick(Cancel As Integer)
Dim strPath As String
If Not IsNull(Me.txtBoxName) Then
strPath = Me.txtBoxName
Me.cmdHyperlink.HyperlinkAddress = strPath
End If
End Sub
 
B

blake7

Instead of using the hyperlink datatype, try using plain text instead. A URL
or file can be connected from a textbox by using code, like:

Sub cmdHyperlink_Click()
Dim strPath As String
If Not IsNull(Me.txtBoxName) Then
strPath = Me.txtBoxName
Me.cmdHyperlink.HyperlinkAddress = strPath
End If
End Sub

where cmdHyperlink is a command button. Double-clicking on the textbox would
work as well.:

Sub txtBoxName_DblClick(Cancel As Integer)
Dim strPath As String
If Not IsNull(Me.txtBoxName) Then
strPath = Me.txtBoxName
Me.cmdHyperlink.HyperlinkAddress = strPath
End If
End Sub
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

Hi Arvin, I created the text box (Hyperlink1) and put the following code in
the double click code area but it still does not work, I am new to VB, what
have I done wrong ?

Thanks. Tony
Private Sub Hyperlink1_DblClick(Cancel As Integer)
Dim strPath As String
If Not IsNull(Me.Hyperlink1) Then
strPath = Me.Hyperlink1
Me.Hyperlink1.HyperlinkAddress = strPath
End If
End Sub
 
A

Arvin Meyer [MVP]

blake7 said:
Hi Arvin, I created the text box (Hyperlink1) and put the following code
in
the double click code area but it still does not work, I am new to VB,
what
have I done wrong ?

Thanks. Tony

Dim strPath As String
If Not IsNull(Me.Hyperlink1) Then
strPath = Me.Hyperlink1
Me.Hyperlink1.HyperlinkAddress = strPath
End If
End Sub

Sorry, the code needs to be different for a text box. Try this:

Private Sub Hyperlink1_DblClick(Cancel As Integer)
Dim strPath As String
If Not IsNull(Me.Hyperlink1) Then
strPath = Me.Hyperlink1
Application.FollowHyperlink strPath
End If
End Sub
 
B

blake7

Arvin Meyer said:
Sorry, the code needs to be different for a text box. Try this:

Private Sub Hyperlink1_DblClick(Cancel As Integer)
Dim strPath As String
If Not IsNull(Me.Hyperlink1) Then
strPath = Me.Hyperlink1
Application.FollowHyperlink strPath
End If
End Sub
 
A

Arvin Meyer [MVP]

If the field is either unbound, or a plain text field, the code above will
work. I just tested it and it works fine. I rarely use hyperlink fields
because they use more resources and have a larger data footprint than a text
field and cannot be indexed.
 

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