By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,970 Members | 1,669 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,970 IT Pros & Developers. It's quick & easy.

Using Hyperlinks

P: n/a
Tom
I have a project database in which I use hyperlinks to call up various
related supporting documents (e.g., proposals, contracts, reports,
site photos, etc.). The documentes are in Word, Excel, PDF and JPG
formats and are all stored in a documents subfolder on my computer. I
use a form with several Hyperlink text boxes (one for each type of
document) which are bound to a table that stores the hyperlinks. I
want the text box to respond to three conditions: 1)null value; 2) a
valid hyperlink address, and; 3) invalid hyperlink address (in the
event a document is deleted or moved).

I am able to satisfy the first two conditions with the following code
that is run when the text box is clicked:
=====================================
Private Sub txtWorkplan_Click()
On Error GoTo Exit_txtWorkplan_Click

Me.Refresh

If IsNull(Me.txtWorkplan) Then
GoTo FindFile_txtWorkplan_Click
Else
GoTo OpenHyperlink_txtWorkplan_Click
End If

OpenHyperlink_txtWorkplan_Click:
DoCmd.RunCommand (acCmdOpenHyperlink)
GoTo Exit_txtWorkplan_Click

FindFile_txtWorkplan_Click:
Beep
Dim FindMessage As String
FindMessage = "Click 'OK' to browse for document file to be
registered in this field"
intResponse = MsgBox(FindMessage, vbOKCancel, "Register Document")
If intResponse = 2 Then
Beep
Else
DoCmd.RunCommand (acCmdEditHyperlink)
End If
GoTo Exit_txtWorkplan_Click

Exit_txtWorkplan_Click:
Exit Sub

Err_txtWorkplan_Click:
Beep
Resume Exit_txtWorkplan_Click

End Sub
====================================

My problem is that I am unable to trap the standard error message that
arises when the hyperlink address is invalid (Unable to open
[filename]. Cannot open the specified file.) in order to initiate a
sub-routine that goes directly to
"DoCmd.RunCommand (acCmdEditHyperlink)" instead of the standard error
message. I can't seem to do it with "On Error"

I'm a self taught hack so please be specific...

Thanks in advance.

Tom
Nov 13 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Tom wrote:
I have a project database in which I use hyperlinks to call up various
related supporting documents (e.g., proposals, contracts, reports,
site photos, etc.). The documentes are in Word, Excel, PDF and JPG
formats and are all stored in a documents subfolder on my computer. I
use a form with several Hyperlink text boxes (one for each type of
document) which are bound to a table that stores the hyperlinks. I
want the text box to respond to three conditions: 1)null value; 2) a
valid hyperlink address, and; 3) invalid hyperlink address (in the
event a document is deleted or moved).

I am able to satisfy the first two conditions with the following code
that is run when the text box is clicked:
=====================================
Private Sub txtWorkplan_Click()
On Error GoTo Exit_txtWorkplan_Click

Me.Refresh

If IsNull(Me.txtWorkplan) Then
GoTo FindFile_txtWorkplan_Click
Else
GoTo OpenHyperlink_txtWorkplan_Click
End If

OpenHyperlink_txtWorkplan_Click:
DoCmd.RunCommand (acCmdOpenHyperlink)
GoTo Exit_txtWorkplan_Click

FindFile_txtWorkplan_Click:
Beep
Dim FindMessage As String
FindMessage = "Click 'OK' to browse for document file to be
registered in this field"
intResponse = MsgBox(FindMessage, vbOKCancel, "Register Document")
If intResponse = 2 Then
Beep
Else
DoCmd.RunCommand (acCmdEditHyperlink)
End If
GoTo Exit_txtWorkplan_Click

Exit_txtWorkplan_Click:
Exit Sub

Err_txtWorkplan_Click:
Beep
Resume Exit_txtWorkplan_Click

End Sub
====================================

My problem is that I am unable to trap the standard error message that
arises when the hyperlink address is invalid (Unable to open
[filename]. Cannot open the specified file.) in order to initiate a
sub-routine that goes directly to
"DoCmd.RunCommand (acCmdEditHyperlink)" instead of the standard error
message. I can't seem to do it with "On Error"

I'm a self taught hack so please be specific...

Thanks in advance.

Tom


Maybe consider using Dir() if the hyperlink uses a folder path name. If
Dir() returns a "" then the file does not exist. Then you can call the
API at hppt://www.mvps.org/access to do a file/open dialog.
Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.