Hyperlink went crazy

danikuper

Registered User.
Local time
Today, 08:20
Joined
Feb 6, 2003
Messages
147
Hi there,

I'm running Access 2000 and have the following problem:

In my form, I have a text box (F_Path) with the file path to a word document. The code I'm using to open it works great, but when there's no path or an invalid path, it brings up an unfriendly error message with the options to "stop" or "debug".

I tried several things to customize the message and stop the procedure of opening the file but nothing works... after the error message, it opens the last file I had opened!!!!

Really strange... well, here's the code I'm using. I hope someone can point me to the right direction, this must be something very simple to fix.

Thanks!!!!

Private Sub cmdOpenFile_Click()
Dim ctl As CommandButton

On Error GoTo Err_cmdOpenFile_Click

Set ctl = Me!cmdOpenFile
With ctl
.HyperlinkAddress = [F_Path]
.Hyperlink.Follow
End With

Exit Sub

Err_cmdOpenFile_Click:
MsgBox ("File not found. Check path and make sure you have a mapped drive to the folder.")

Exit Sub

End Sub
 
Code:
Private Sub cmdOpenFile_Click()
On Error GoTo Err_cmdOpenFile_Click

    If IsNull(Me.F_Path) Then
        MsgBox "Please Enter the Path and File Name", vbCritical, "Enter Path and File Name"
    Else
        Application.FollowHyperlink Me.F_Path, , True, False
    End If

Err_cmdOpenFile_Click:
    If Err = 490 Then
        Err.Clear
        MsgBox "File not found. Check path and make sure you have a mapped drive to the folder.", vbCritical, "File not found"
        DoCmd.CancelEvent
    Else

    End If

Exit Sub

End Sub
HTH
 
Last edited:
Thanks!

Works great!!!!

Thanks a lot :)

daniel
 

Users who are viewing this thread

Back
Top Bottom