Inserting Hyperlinks into table fields

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

Guest

Hi I hope soemone can help. I want to insert a hyperlink into a table field
using VBA Code. I also want the display name to be different form the
hyperlink address.

Cheers

Nick
 
Hi, Nick.
I want to insert a hyperlink into a table field
using VBA Code.

To insert a record into the table, try:

Private Sub InsertRecBtn_Click()

On Error GoTo ErrHandler

CurrentDb().Execute "INSERT INTO tblHyperlinks (HypLink) " & _
"VALUES ('Text to display#" & _
"C:\Data\MyFile.txt##" & _
"C:\Data\MyFile.txt');", dbFailOnError

Exit Sub

ErrHandler:

MsgBox "Error in InsertRecBtn_Click( ) in" & vbCrLf & _
Me.Name & " form." & vbCrLf & vbCrLf & _
"Error #" & Err.Number & vbCrLf & vbCrLf & Err.Description
Err.Clear

End Sub ' InsertRecBtn_Click( )

.. . . where tblHyperlinks is the name of the table, HypLink is the name of
the field, "Text to display" is the text string to be displayed in the
hyperlink field, and C:\Data\MyFile.txt is the path to the file.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.
 
Thanks, that has worked a treat

'69 Camaro said:
Hi, Nick.


To insert a record into the table, try:

Private Sub InsertRecBtn_Click()

On Error GoTo ErrHandler

CurrentDb().Execute "INSERT INTO tblHyperlinks (HypLink) " & _
"VALUES ('Text to display#" & _
"C:\Data\MyFile.txt##" & _
"C:\Data\MyFile.txt');", dbFailOnError

Exit Sub

ErrHandler:

MsgBox "Error in InsertRecBtn_Click( ) in" & vbCrLf & _
Me.Name & " form." & vbCrLf & vbCrLf & _
"Error #" & Err.Number & vbCrLf & vbCrLf & Err.Description
Err.Clear

End Sub ' InsertRecBtn_Click( )

. . . where tblHyperlinks is the name of the table, HypLink is the name of
the field, "Text to display" is the text string to be displayed in the
hyperlink field, and C:\Data\MyFile.txt is the path to the file.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.
 
'69 Camaro said:
Hi, Nick.


To insert a record into the table, try:

Private Sub InsertRecBtn_Click()

On Error GoTo ErrHandler

CurrentDb().Execute "INSERT INTO tblHyperlinks (HypLink) " & _
"VALUES ('Text to display#" & _
"C:\Data\MyFile.txt##" & _
"C:\Data\MyFile.txt');", dbFailOnError

Exit Sub

ErrHandler:

MsgBox "Error in InsertRecBtn_Click( ) in" & vbCrLf & _
Me.Name & " form." & vbCrLf & vbCrLf & _
"Error #" & Err.Number & vbCrLf & vbCrLf & Err.Description
Err.Clear

End Sub ' InsertRecBtn_Click( )

. . . where tblHyperlinks is the name of the table, HypLink is the name of
the field, "Text to display" is the text string to be displayed in the
hyperlink field, and C:\Data\MyFile.txt is the path to the file.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.
 
Hello,
I have the same question, only I'm not at such an advanced level that I
could follow the above post without a few more details. I have a table with
the names of organizations in one field and another field with the URLs. I
know how to manually change the "Display Text, " but I have hundreds of
entries and more to come. This code appears to do what I want. Could you
please give a few more step-by-step instructions? I'm a novice when it comes
to code, but I'm determined! Thanks!
 
Back
Top