Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Allow User to Create Hyperlink

Status
Not open for further replies.

Costefran

Technical User
Jan 2, 2008
197
GB
Hi Can anyone help

I have been considering how I can attach a file (Word Doc or PDF) to a record in Access and have been told to avoid this as the DB will soon become bloated so I thought maybe there is a way that a user can create a Hyperlink on a form through a command button 'on click' event that browses for the file and location and then place the file path on the form for future users to click on and open the file

Does anyone know if this is possible

Thanks
 
This is a bit rough and it does not error trapping or any type of checks but, you can get the file name and path to save to a table and then use rundll32 to run diffrent file types if that is what you are looking for.

I created a simple table to hold the hyperlink and just used a bound form to hold the file name along with the path.

I also created a simple "Run" button to open various file types.

Needs work but this should get you going.

Code:
Option Compare Database

Private Sub cmdFilePath_Click()
Dim sFilePath As String
Dim fd As FileDialog

Set fd = Application.FileDialog(msoFileDialogFilePicker)
    fd.Filters.Clear
    fd.Show

sFilePath = fd.SelectedItems(1)
txtFilePath.SetFocus
txtFilePath.Text = sFilePath

End Sub

Private Sub cmdRun_Click()
txtFilePath.SetFocus
Shell "RunDLL32.EXE shell32.dll,ShellExec_RunDLL " & Trim(txtFilePath.Text)
End Sub
 
CaptainD

Thanks very much for you ehlp

Will give it a try

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top