Command to open file

G

Guest

Hello!

I would like to know how to specify a field's contents in a command button.
I'm using Access 2000 here at work.

I have a field 'Program File Name' that I have the full path name to a file
stored. I have assed a command button to open up the preferred editor for
these file types, and that command works just fine. Now I would like to open
the file specified in the above field. Note: each record has a unique file
specified in the field.

Below is the coding for the Event Procedure:

Private Sub c_OpenCodeFile_Click()
On Error GoTo Err_c_OpenCodeFile_Click

Dim stAppName As String

stAppName = "C:\mcamx\common\editors\mastercam\MCXStart.exe"
Call Shell(stAppName, 1)

Exit_c_OpenCodeFile_Click:
Exit Sub

Err_c_OpenCodeFile_Click:
MsgBox Err.Description
Resume Exit_c_OpenCodeFile_Click

End Sub

Thank you in advance for any help! I really appreciate it.
~Kathy
 
K

Keith W

Kathy R said:
Hello!

I would like to know how to specify a field's contents in a command
button.
I'm using Access 2000 here at work.

I have a field 'Program File Name' that I have the full path name to a
file
stored. I have assed a command button to open up the preferred editor for
these file types, and that command works just fine. Now I would like to
open
the file specified in the above field. Note: each record has a unique file
specified in the field.
Couldn't you just use a hyperlink field to store the path in? No code
required at all and you can store paths to just about any file type and have
the correct application open for free.

Keith.
www.keithwilby.com
 
G

Guest

Keith -

But wouldn't a hyperlink open the same file on each record? I need to open
unique files for each record.

Plus - I would like to have the option of data entry (file name and path)
into a field rather than emmbedding the info into the design.

Thanks, Kathy
 
K

Keith W

Kathy R said:
Keith -

But wouldn't a hyperlink open the same file on each record? I need to open
unique files for each record.

Plus - I would like to have the option of data entry (file name and path)
into a field rather than emmbedding the info into the design.

Thanks, Kathy
What I was suggesting was having a hyperlink *field* in your table with a
text box bound to it on your form. Each record would have it's own data in
the field, thus linking it to whatever file the user navigates to.

Regards,
Keith.
www.keithwilby.com
 
A

Albert D.Kallal

If you have the path name to the document in a field, then you can "launch"
that file and the correct application will load also.

Just go:

application.FollowHyperlink me.MyFieldNameWithPathToDocument

So, you don't even have to use the "shell" function.
 

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