The attachment feature gives developers the opportunity to offer compact and portable solutions to a wide new market. No more trying to keep track of files and update hyperlinks when files are moved or deleted. Using the attachment field type automatically compresses the file and stores it in the database. Multiple files and file types—resumés as Word documents, some JPG photos, an Excel spreadsheet, or even a PowerPoint file—can be stored in a single field or record. Access actually creates system tables to normalize the data. You cannot view or work with these tables, and once the data type is set to attachment, it cannot be changed. This makes sense because it would essentially create orphaned system tables and records. Although you can't work with the system tables, you can programmatically work with the attachments. The Import RunCommand macro and the acCmdImport have been replaced with the ImportAttach command.
The Attachments dialog box makes it easy to add, edit, remove, and save attachments. The dialog box opens directly from an attachment field in a table or when using the attachment control on a form or report. Because a record can have multiple attachments, it is handy to be able so save multiple attachments at one time. It is one or all, but that is still better than being limited to one at a time. If the attachment's parent program is installed on the computer, the attachment can be opened and edited with that program. You can save the edited file back to the database or to a different folder. Because reports do not allow edits, an attachment opened from a report can only be saved to a different location.
You must be wondering about file types and sizes. Suffice it to say that you can attach just about any file created in the 2007 Microsoft Office System as well as log files, text files, zip files, and most image files. There are a few file formats that are blocked and therefore can't be saved as attachments. Because that list is likely change, it is best to check for updated information on Microsoft's MSDN website. Appendix L lists the file types for attachments when discussing naming conventions.
Access still has a maximum file size of 2-gigabytes, so there is plenty of room for photos and just about anything else you can think of. Each attachment can be a whopping 256 megabytes, so there is no need to sacrifice quality. And, as previously mentioned, Access conveniently compresses files as when it creates the attachments (that is unless the file is already compressed in its native format, such as JPEG files).
Unlike previous versions of Access that stored attachments as bitmap images that could be 10 times larger than the actual file, Access 2007 compresses files in their native format. So Access opens attachments and allows them to be edited in their parent program.
Was this article helpful?