Avatar of Phereklos
Phereklos

asked on 

Button to open attachment in Access 2007

A few questions

First, how can I program a form button to open a specific attachment?  I want the button on click to go to an table and open a specific attachment.

Second, why I was thinking about this.  I want to include a button on my form to open an explanation or guide for the form.  I thought about opening another form or report, but then thought about having this guide in pdf format.  So I would have a table called tblGuides which would consist of a autonumber field, description text field and and an attachment field.  The "Form Guide" button on my form frmLeasing would open the Leasing Form Guide, presumably by finding the autonumber.

Let me know if this makes sense at all, or if I am barking up the wrong tree.

Thanks
Microsoft Access

Avatar of undefined
Last Comment
irritablebadger
Avatar of jpipkins
jpipkins

Seems like it would be better to store the path to the attachment instead of actually attaching the file.  Then you could use the shell statement and let the OS determine the correct app to load for the file extension.
SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Similar to jpipkins post...

Again, instead of actually storing the File in the database using an Attachment filed, you could use a Hyperlink Field.
Then you would just need to clik the hyperlink to open the file.

As far as your second question is concerned...
If you use the shell or the hyperlink approach, the file will open up in it's own window.
You could display the file in the form itself, by using an image control or the WebBrowser control.

Is the File tied to a record on the form?
Is this an Image File?

Thanks

JeffCoachman
A2007 has a new type of Data type field called Attachment.
Avatar of Phereklos
Phereklos

ASKER

I gather that there is no way to open a specific attachment using a command.  

Does anyone ever provide end users a "guide to form" or something similar?  I'd like to have button at the top of the form that opens a set of instructions and answers any questions the end user may have about this form.  Should I have this button open another form or a report or something else, and how would I best implement it?
ASKER CERTIFIED SOLUTION
Avatar of jpipkins
jpipkins

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Phereklos,

1. You keep saying "Attachments"
As I mentioned in my previous post, you can open any *file* by using the Shell command or a Hyperlink.
This would be what you are calling "Opening with a command"
(Does this absolutely have to be an "Attachment" field?)

jpipkins, and capricorn1, posted other appoaches as well.

2. You have not stated if you even tested any of our posts?

3. If you are now moving this question into a "How do I design a Guide to Form" question, then this is a totally different question than what you originally posted.

I suggest you try each of our suggestions in sequence and decide which one solves you initial issuse.
Then award the points.

You can post your "Design" question as a New question.
;-)

Thanks

JeffCoachman

You can call up the "Manage Attachments" dialog box with a button. This provides the same functionality as left-clicking on the attachment field then clicking "Manage Attachments but without training or the crappy user experience.

This is sort of nice as it give the user the ability to browse to the file they want to attach vs. lots of coding for the Windows file browser dialog and keeping track of the current recordset - the Manage Attachments dialog handles it all for you.

You can use the same code behind whatever button you choose - Add Document, Delete Document, Open Document, etc... The user won't think twice about it.



Private Sub btnOpenDocument_Click()
DoCmd.GoToControl "MyAttachment"
Application.RunCommand (acCmdManageAttachments)
End Sub
 
'MyAttachmet is the name of the Attachment control on the form

Open in new window

Microsoft Access
Microsoft Access

Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.

226K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo