How to: Work With Attachments In DAO
Office 2007
| Access Developer Reference |
In DAO, Attachment fields function just like other multi-valued fields. The field that contains the attachment contains a recordset that is a child to the table's recordset. There are two new DAO methods, LoadFromFile and SaveToFile, that deal exclusively with attachments.
Add an Attachment to a Record
The LoadFromFile method loads a file from disk and adds the file as an attachment to the specified record. The syntax of the LoadFromFile method is as follows:
|
Note |
|---|
| The FileData field is reserved internally by the Access database engine to store the binary attachment data. |
The following code snippet uses the LoadFromFile method to load an employee's picture from disk.
|
Save an Attachment to Disk
The following code snippet illustrates how to use the SaveToFile method to save all of the attachments for a specific employee to disk.
|
Note