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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hyperlink

Status
Not open for further replies.

NRK

Technical User
Feb 13, 2002
116
US
I have created a Browse feature that allows users to add relevant files (primarily .doc, .xls, .txt) to record in a form. The purpose is that they can reference these files and that management can easily access these files without searching for them.

I have created the code (using MS Common Dialog, version 6) and it works fine. But...my problem is that I cannot get the file to open when I click on the link (file name is displayed as a hyperlink). I can get it to work if I go into my table and click on the Insert Hyperlink button in the Toolbar.

Can anyone help me figure out some VB that will allow users to open the files from the text field once they add the file?

Any assistance would be greatly appreciated!
 
Don't forget to call the follow method of the hyperlink as:
Code:
Private Sub FollowLink(sPath As String)
    Dim hlk As Hyperlink
    Set hlk = cmdSupportFiles.Hyperlink
    hlk.Address = sPath
    hlk.Follow
    Set hlk = Nothing
End Sub
[\code]

Hope this helps,
Rewdee
 
Rewdee,
Thanks for the quick response. I am unsure where I need to apply this or what your variables (sPath and hlk) are.

Here is the code that I am currently using:
Private Sub cmdBrowse_Click()
Dim strNewFile As String

On Error GoTo Browse_Err
With Me.cdlgOpen
.InitDir = EXISTINGDIR
.CancelError = True
.Filter = ("Word Files|*.doc|Text Files|*.txt|Excel Files|*.xls|All Files|*.*")
.ShowOpen
strNewFile = .FileName
End With

Me.txtTcLink = strNewFile
'This is my text field that is formatted as a hyperlink

Browse_Exit:
Exit Sub

Browse_Err:
If Err.Number = 32755 Then
Resume Browse_Exit
Else
MsgBox Err.Number & ": " & Err.Description
Resume Browse_Exit
End If
End Sub


Thanks, again.
 
Simply change the
Code:
Me.txtTcLink=strNewFile
TO:
Code:
me.txtTcLink.Address=strNewFile
me.txtTcLink.Follow

Best Regards,
Rewdee
 
Rewdee,
I appreciate the follow-up. I made the change you recommended, but get a Compile error stating that the "method or data member not found". I believe that is because I am not utilizing the first code (Sub FollowLink) that you sent me. If this is the issue, please explain how I would set this up.

Thank you for your effort. Although I would think this task should be simple, I seem to be stuck.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top