Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opening Files in Access Form

Status
Not open for further replies.

HeathRamos

IS-IT--Management
Apr 28, 2003
112
US
I am trying to design a database that opens pdf files within an Access 2000 form.

I have read previous posts here but can't seem to get it right.

I created an event procedure and inserted the following:

Dim db As DAO.Database, rst As DAO.Recordset

Set db = CurrentDb()
Set rst = db.OpenRecordset("InfoTable")
Dim strFile As String

strFile = rst![Resume]

FollowHyperlink strFile

The field Resume is a text field that contains \\servername\filename.

When I click on the button in the form, it does open the file but only for the first record. To clarify, I have a form based on the InfoTable table and a button with this event procedure on it. I would like for it to open a different file for each record. Right now it opens the initial file for every record.
 
You need to loop through the records and perform the opening.

Assuming that each record has a different file name in the [Resume] field.

Something like this

Dim db as dao.database
Dim rst as dao.recordset
Dim strFile as string

set db = CrurentDb()
set rst=db.openrecordset("InfoTable")
Do while not rst.eof
strFile = rst![Resume]
followhyperlink strfile
rst.movenext
loop


This should open every document it finds. I would caution you to not open the table but to open a query based on the current applicant or whatever depending on your application.

I assume you only want to open certain documents not all of them

Andy




Andy Baldwin
 
Something like this ?
FollowHyperlink Me![Resume]

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
wouldn't doing a loop open every document in the table at the same time?

I want a form based on a table and when you are on a certain record, the command button will open the link for that record located in it's corresponding field.

For more detail:

Table has first name, last name, autonum as pk, and resume that has \\servername\filename.

Form created off of that table and includes the pk, first name and last name.

Form also has command button which should open the file associated with that record (file location in resume field).
 
If you see my original post the last thing I wrote was

"This should open every document it finds. I would caution you to not open the table but to open a query based on the current applicant or whatever depending on your application.

I assume you only want to open certain documents not all of them"

If you are on the record you want in a form I would write a piece of vba behind a button that would use the Shell function to open whatever is listed in the controll listing the file name. There are plenty of Shell command snipets around. I can dig up one I used somewhere if you like. This has the added benefit of opening any type of document that your machine can view (i.e. Docs, pdf, bmps, etc.) using the default viewer of your machine.



Andy Baldwin

"Testing is the most overlooked programming language on the books!
 
OOps, reread your last post.
My suggestion (one-liner) works if you have a control (even hidden) named resume bound to the corresponding field.
 
I think PHV's suggestion worked.

I will play around with it a little more.

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top