Page 2You use the Attachment feature in Access to add one or more files — documents, presentations, images, and so on — to the records in your database. This article provides the background information and steps needed to configure a database to use attachments, and to attach and manage data.
Note: The functionality explained in this article doesn't apply to Access web apps. You can use attachments to store several files in a single field, and you can even store multiple types of files in that field. For example, let's say you own a job contacts database. You can now attach one or more resumes to the record for each contact, plus a photo of each contact. Attachments also store data more efficiently. Earlier versions of Access used a technology called Object Linking and Embedding (OLE) to store images and documents. By default, OLE created a bitmap equivalent of the image or document. Those bitmap files could become quite large — as much as 10 times larger than the original file. When you viewed an image or a document from your database, OLE showed you the bitmap image, not the original file. By using attachments, you open documents and other non-image files in their parent programs, so from within Access, you can search and edit those files. In addition, OLE requires programs called OLE servers to function. For example, if you store JPEG image files in an Access database, every computer that runs that database requires another program that is registered as an OLE server for JPEG images. In contrast, Access stores the attached files in their native formats with no supporting images, and you do not need to install additional software in order to view the images from within your database. By default, each field in a relational database contains only one piece of data. For example, if an address field contained more than one address, finding addresses would be difficult, if not impossible. So at first glance, attachments seem to break the rules of database design because you can attach more than one file — one piece of data — to a field. However, attachments do not break any design rules, because as you attach files to a record, Access creates one or more system tables and uses those tables behind the scenes to normalize your data. You cannot view or work with those tables. For information about viewing other system tables, see the article Guide to the Navigation Pane. For information about database design, see the article Database design basics. Remember these guidelines as you work with attached files:
The steps in the following sections explain how to add and manage attachments. Top of Page To use attachments in Access, you must first add an attachment field to at least one of the tables in your database. Access provides two ways to add an attachment field to a table. You can add the field in Datasheet view, or you can add it in Design view. The steps in this section explain how to use both techniques.
Top of Page After you add an attachment field to a table, you can attach the files to the records in that table without having to create a data-entry form. You can also view attachments without using a form, but remember that when you view attachments directly from tables, you must do so in the programs that were used to create the files, or in a program that supports that type of file. For example, if you open a Word document that is attached to a table, Word also starts and you view the document from within Word, not Access. If Word is not installed on your computer, a dialog box appears and asks you to select a program for viewing the file.
Top of Page When you need to use attachments with a form or report, you use the attachment control. The control renders image files automatically as you move among the records in a database. If you attach other types of files, such as documents or drawings, the attachment control displays the icon that corresponds to the file type. For example, you see the PowerPoint icon when you attach a presentation, and so on. The control also allows you to browse any attached files and open the Attachments dialog box. If you open the dialog box from a form, you can add, remove, edit, and save attachments. If you open the dialog box from a report, you can only save attachments to your hard disk drive or a network location, because reports are read-only by design. The steps in the following sections explain how to add an image control to a form or report, and how to scroll through records, attach files, and view your attachments. Remember that you can scroll through attachments only when a given record contains more than one attachment. The steps in this section explain how to add the attachment control to a form or report, and then bind the control to an Attachment field in an underlying table. You follow the same steps when adding the attachment control to a form or a report. Before you start, remember that at least one of the tables in your database must have an attachment field. For information on adding an attachment field, see Add an attachment field to a table earlier in this article. Because form and report design can be complex processes, the steps in these sections assume that you already have a database with at least one table and one form or report. For information on creating tables, forms, or reports, see the following articles:
After you add an attachment control to a form, you can add, edit, remove, and save attached files directly from that form. When a record contains multiple attachments, you can also scroll through the attached files, which you cannot do when working with a table.
Note: The person who designed the form may have made the form read-only. If that is the case, you can use the Attachments dialog box only to save attached files to your hard disk drive or a location on your network.
Note: The steps in this section apply to forms and reports.
Top of Page The steps in this section apply to tables, forms, and reports. You can save either one or all of the files that are attached to a given record to locations on your hard disk drive or network. Remember that when you choose to save all files, you cannot choose to save some of the files — you must save them all. To selectively save files, you need to do so one at a time.
Open the Attachments dialog box from a table
Open the Attachments dialog box from a form or report
Top of Page The steps in this section apply to tables and forms.
Top of Page The following section explains how to use your keyboard to place focus in the Navigation Pane and open the table, form, or report that contains attached files. The steps also explain how to browse attached files and open the Attachments dialog box.
These steps apply only if you have a Microsoft Natural Keyboard and when a record contains more than one attachment.
These steps apply only if you have a Microsoft Natural Keyboard.
Top of Page The following sections provide reference information about attachments, including the image and document file formats that attachments support, file-naming conventions, and some information about attaching files to records programmatically. Access supports the following graphic file formats natively, meaning the attachment control renders them without the need for additional software. BMP (Windows Bitmap) RLE (Run Length Encoded Bitmap) DIB (Device Independent Bitmap) GIF (Graphics Interchange Format) JPEG, JPG, JPE (Joint Photographic Experts Group) EXIF (Exchangeable File Format) PNG (Portable Network Graphics) TIFF, TIF (Tagged Image File Format) ICON, ICO (Icon) WMF (Windows Metafile) EMF (Enhanced Metafile) As a rule, you can attach any file that was created with one of the Microsoft Office programs. You can also attach log files (.log), text files (.text, .txt), and compressed .zip files. The names of your attached files can contain any Unicode character supported by the NTFS file system used in Microsoft Windows NT (NTFS). In addition, file names must conform to these guidelines:
When you attach any of the following file types to a database, Access compresses them if they are not already compressed natively.
Access blocks the following types of attached files. At this time, you cannot unblock any of the file types listed here.
Access exposes an object model and programming interfaces for attaching files to records programmatically by using Visual Basic for Applications (VBA) code. For information about attaching files programmatically, see the articles "LoadFromFile" and "SaveToFile," on the Microsoft Developer Network — https://msdn.microsoft.com. Top of Page |