G
Gordzilla
I developed a form for a user in Access 2003 works like a charm. He only
has 2000, told me after the fact! Upgrade is not option. Have to change my
forms to work.
The form has 4 command buttons on it that with a coresponding text box
hidden behind it. The command button is supposed to open a hyperlink to a
document, the hyperlink value is stored in the text box. If the text box is
empty, a prompt to add a new hyperlink opens. The user browses to the file
in question, selects it and the hyperlink is pasted into the textbox. When
the record is saved the hyperlink is stored in a hyperlink field in the data
source. In Access 2003 it all works. In access 2000, existing hyperlinks
work, new ones are added but when you try and open one you've added, it's
not recognized and the add prompt comes up. If you close access completely
and go back it all works and the hyperlink is in the table. Debugging has
led to beleive that the problem is with
Application.FollowHyperlink strInput, , True since it evals to false on a
new hyperlink, even if the record is saved, form closed, etc.
Code:
On Click event for button
Private Sub cmdDOC_link_Click()
Dim Response, MyString
On Error GoTo cmdDOC_link_Click_Error
If ValidLink(Me.txtDOC_Link) = False Then
Response = MsgBox("file not found. Would you like to add one now?",
vbYesNo, "Add Document")
If Response = vbYes Then ' User choose Yes.
txtDOC_Link.Visible = True ' text box to hold hyperlink
txtDOC_Link.SetFocus
DoCmd.RunCommand acCmdInsertHyperlink
cmdDOC_link.SetFocus
txtDOC_Link.Visible = False
Else ' User choose No.
MyString = "No" ' Perform some action.
End If
End If
Hyper_Colours
exit_cmdDOC_link_Click:
Exit Sub
cmdDOC_link_Click_Error:
If Err <> 2501 Then
MsgBox Err & ": " & Err.DESCRIPTION
Resume exit_cmdDOC_link_Click
End If
End Sub
Public Function ValidLink(strInput) As Boolean
'Dim strInput As String
On Error GoTo Error_ValidLink
Application.FollowHyperlink strInput, , True
ValidLink = True
Exit_ValidLink:
Exit Function
Error_ValidLink:
' MsgBox Err & ": " & Err.Description
ValidLink = False
Resume Exit_ValidLink
End Function
has 2000, told me after the fact! Upgrade is not option. Have to change my
forms to work.
The form has 4 command buttons on it that with a coresponding text box
hidden behind it. The command button is supposed to open a hyperlink to a
document, the hyperlink value is stored in the text box. If the text box is
empty, a prompt to add a new hyperlink opens. The user browses to the file
in question, selects it and the hyperlink is pasted into the textbox. When
the record is saved the hyperlink is stored in a hyperlink field in the data
source. In Access 2003 it all works. In access 2000, existing hyperlinks
work, new ones are added but when you try and open one you've added, it's
not recognized and the add prompt comes up. If you close access completely
and go back it all works and the hyperlink is in the table. Debugging has
led to beleive that the problem is with
Application.FollowHyperlink strInput, , True since it evals to false on a
new hyperlink, even if the record is saved, form closed, etc.
Code:
On Click event for button
Private Sub cmdDOC_link_Click()
Dim Response, MyString
On Error GoTo cmdDOC_link_Click_Error
If ValidLink(Me.txtDOC_Link) = False Then
Response = MsgBox("file not found. Would you like to add one now?",
vbYesNo, "Add Document")
If Response = vbYes Then ' User choose Yes.
txtDOC_Link.Visible = True ' text box to hold hyperlink
txtDOC_Link.SetFocus
DoCmd.RunCommand acCmdInsertHyperlink
cmdDOC_link.SetFocus
txtDOC_Link.Visible = False
Else ' User choose No.
MyString = "No" ' Perform some action.
End If
End If
Hyper_Colours
exit_cmdDOC_link_Click:
Exit Sub
cmdDOC_link_Click_Error:
If Err <> 2501 Then
MsgBox Err & ": " & Err.DESCRIPTION
Resume exit_cmdDOC_link_Click
End If
End Sub
Public Function ValidLink(strInput) As Boolean
'Dim strInput As String
On Error GoTo Error_ValidLink
Application.FollowHyperlink strInput, , True
ValidLink = True
Exit_ValidLink:
Exit Function
Error_ValidLink:
' MsgBox Err & ": " & Err.Description
ValidLink = False
Resume Exit_ValidLink
End Function