Hyperlink to a file

N

nybaseball22

Hello. I am trying to setup a command button on a form that will
allow me to assign a hyperlink that will automatically open a file
(word, excel, pdf, etc) when I click on it. However, I am unsure how
to setup the code that will allow me to create the hyperlink. So far,
I have a field (FileHyperlink) in my table (ExpensesMain) that is
setup as a hyperlink field. Is there a way to have a command button
open up a dialog box that I can search for the file I want to assign,
select it, and have it assigned to the tect box on my form (Text box
name: txtFileHyperlink - Form Name: ExpensesDetail)?

Thank you.
 
A

Arvin Meyer [MVP]

Just a regular textbox, holding the full path to the file. In a form, refer
use code like:

Private Sub cmdHyperlink_Click()
Dim strPath As String
If Not IsNull(Me.txtBoxName) Then
strPath = Me.txtBoxName
Me.cmdHyperlink.HyperlinkAddress = strPath
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