Opening files from other applications within Access

G

Guest

In general, I know how to open a file within Access. You would use a macro or
within a form, choose RunApp with the path to the executable and the filename
as it's argument.

What I have been asked to do seems to be more complicated than that.

For example...

The database contains information on a project and there is a file
associated with it (a word or pdf file for instance). People would look for
certain criteria, choose a project and then want to open the file by clicking
on a button (not by typing a file name or browsing for it). Not only that,
but they want someone to be able to add new projects to it (manually enter
info into a form), copy the associated file to a specific location and have
it work like the others (meaning no one would have to adjust the form or add
a macro for it to work).

Even if we came up with a naming convention for the files (based off a
primary key or project name), how do you open a file with a variable file
name?

Maybe would have to use visual basic, not sure.
 
D

Douglas J Steele

Yeah, you're going to want to use VBA here, not a macro.

Assuming that the file's extension has been associated with a particular
application, you can use the FollowHyperlink method:

FollowHyperlink "C:\Documentation\ReadMe.txt"

or

strFile = "C:\Documentation\ReadMe.txt"
FollowHyperlink strFile
 
G

Guest

ok...

my thought would be then to store the link in a table associated with the
record and then open the link in an event procedure.

How do you get info from a table within access into an event procedure?

For example: table1 contains a filed called hyperfield.

so...the strFile=table1.hyperfield and then FollowHyperlink strFile.

just not sure how to do it exactly.
 
D

Douglas J. Steele

It depends.

Are we talking one row in the table, or multiple? If multiple, do you want
to process them one after the other, or do you want them to appear on a form
with a button beside so that you can pick and choose?
 

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