How do I use VBA to open an Attachment directly from record? (1 Viewer)

joshuar

New member
Local time
Today, 12:31
Joined
Dec 15, 2020
Messages
9
Access Attachment.JPG

When interfacing with attachments, the "double click" and the "Open" buttons open the attachment. From there the document can be edited and, when saved, it updates the attachment record directly. If user tried to close the "Attachments" window while the document was still open, the user is even warned that the document is still being edited.

Question is, what is the VBA code to replicate this action (opening the document within the record directly)?

I already have the code to copy the attachment to a temp directory and open it, but that is just opening a copy. When it's saved, it's not saved directly to the record it was opened from; the user has to delete the original and re-upload it to update the record, not what I'm looking to do. What's behind these buttons?
 

isladogs

MVP / VIP
Local time
Today, 11:31
Joined
Jan 14, 2017
Messages
18,186
Attachment field data is stored in a 'deep hidden' table which makes interacting with that data far from straightforward using VBA.
In addition, attachment fields cause significant database bloat and are best avoided.

I would recommend you instead store the files externally and store the file paths in Access.
This will have several benefits:
1. File size will be reduced
2. Performance will be better
3. Using code to open the files will be trivial

Also, welcome to AWF
 

Users who are viewing this thread

Top Bottom