S
silva
I have a form with multiple pages (each page has its own subform), and on a
fw of them I have a button that opens a file, of which the file path is
entered into field labeled [file_path]. I use the following VBA code in all
instances I use the button:
Private Sub open_survey_button_Click()
On Error GoTo Err_open_survey_button_Click
Application.FollowHyperlink Me.[file_path]
Exit_open_survey_button_Click:
Exit Sub
Err_open_survey_button_Click:
MsgBox ("Can not open file. Please check file name and path.")
[file_path].SetFocus
Resume Exit_open_survey_button_Click
End Sub
For each instance it is used, I change "survey" so it's more meaningful to
the specific page and subform. However, for some reason, on one page only the
button will not open the target file, but it will start the appropriate
application for the file format. If I change the extension for the target
file, it does display the error and move focus back to the [file_path] field
to correct the mistake, as it should. So it does recognize that the file
exists (or it seems to, anyway). Is there something I need to look at,
change, or fix in order to get this to work properly? This code works fine
everywhere else it is used to do the same exact thing, so I'm quite confused.
fw of them I have a button that opens a file, of which the file path is
entered into field labeled [file_path]. I use the following VBA code in all
instances I use the button:
Private Sub open_survey_button_Click()
On Error GoTo Err_open_survey_button_Click
Application.FollowHyperlink Me.[file_path]
Exit_open_survey_button_Click:
Exit Sub
Err_open_survey_button_Click:
MsgBox ("Can not open file. Please check file name and path.")
[file_path].SetFocus
Resume Exit_open_survey_button_Click
End Sub
For each instance it is used, I change "survey" so it's more meaningful to
the specific page and subform. However, for some reason, on one page only the
button will not open the target file, but it will start the appropriate
application for the file format. If I change the extension for the target
file, it does display the error and move focus back to the [file_path] field
to correct the mistake, as it should. So it does recognize that the file
exists (or it seems to, anyway). Is there something I need to look at,
change, or fix in order to get this to work properly? This code works fine
everywhere else it is used to do the same exact thing, so I'm quite confused.