Catch Hyperlink Error

B

Brad

Thanks for taking the time to read my question.

I have a label with a Hyperlink Address. When the user clicks on it, the
web page opens. The web page is a local file found on the users hard drive.
If that file gets moved, and you click on the link, an error comes up saying
that the file cannot be found.

How do I catch that error and deal with it?

Thanks,

Brad
 
S

Stefan Hoffmann

hi Brad,
I have a label with a Hyperlink Address. When the user clicks on it, the
web page opens. The web page is a local file found on the users hard drive.
If that file gets moved, and you click on the link, an error comes up saying
that the file cannot be found.
How do I catch that error and deal with it?
If it's always a local file, you may use Dir() to check if it exists.


mfG
--> stefan <--
 
B

Brad

Good point, but then I have to make an onClick event instead of just relying
on the fact that if there is a Hyperlink Address, it just opens the file
without an onClick event.

Brad
 
B

Brad

I went for the onClick event...

here's my code

N.B. ListFiles is a seperate function

Private Sub AssetMgtHelp_Click()
On Error GoTo AssetMgtHelp_Click_Err

Dim dbs As Database
Dim rst As DAO.Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tblDefaults")

rst.MoveFirst

Dim hlk As Hyperlink
Dim strAddress As String
Set hlk = Me.AssetMgtHelp.Hyperlink

strAddress = rst!HelpFilePath



If Dir(strAddress) <> "" Then

With hlk
.Address = strAddress & "#AssetForm"
End With

Else

With hlk
.Address = strAddress & "#AssetForm"
.Follow
End With

End If



AssetMgtHelp_Click_Exit:
rst.Close
Set dbs = Nothing
Exit Sub


AssetMgtHelp_Click_Err:
If Err.Number = 432 Then
MsgBox "Help File Not Found. The computer will try to locate the
folder.", 64
DoCmd.OpenForm "frmSearching"
ListFiles "C:\", "AssetDataDBHelpFile.htm", True
If FoundTheFile <> "" Then
rst.MoveFirst
With rst
.Edit
!HelpFilePath = FoundTheFile
.Update
End With
MsgBox "Complete!", vbExclamation
Else
MsgBox "Missing Help Files. Please check the install file for
the associated help files. They are in .htm format."
End If
DoCmd.Close acForm, "frmSearching", acSaveNo


rst.MoveFirst
strAddress = rst!HelpFilePath & "#AssetForm"
With hlk
.Address = strAddress
End With
Else
MsgBox Err.Number & ", " & Err.Description
Resume AssetMgtHelp_Click_Exit
End If
End Sub

Brad
 

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