Opening a File Within a Form Using Access 2003

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.
 
T

Tom van Stiphout

On Tue, 19 Aug 2008 14:41:01 -0700, silva

You're leaving out some important information, for example: can you
open the file manually in the host application?

-Tom.
Microsoft Access MVP
 
S

silva

Yes, the document will open normally if you browse through the folders and
double-click it, and it will open if you use the application to open it, as
well.

Tom van Stiphout said:
On Tue, 19 Aug 2008 14:41:01 -0700, silva

You're leaving out some important information, for example: can you
open the file manually in the host application?

-Tom.
Microsoft Access MVP

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.
 

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