Field2.SaveToFile Method

Access Developer Reference

Saves an attachment to disk. .

Version Information
 Version Added:  Access 2007

Syntax

expression.SaveToFile(FileName)

expression   A variable that represents a Field2 object.

Parameters

Name Required/Optional Data Type Description
FileName Required String The fully qualified path of the file to which you want to save the attachment.

Example

The following code snippet illustrates how to use the SaveToFile method to save all of the attachments for a specific employee to disk.

Visual Basic for Applications
  '  Instantiate the parent recordset. 
   Set rsEmployees = db.OpenRecordset("Employees")
 
   … Code to move to desired employee
 
   ' Instantiate the child recordset.
   Set rsPictures = rsEmployees.Fields("Pictures").Value 

' Loop through the attachments. While Not rsPictures.EOF

  '  Save current attachment to disk in the "My Documents" folder.
  rsPictures.Fields("FileData").SaveToFile _
              "C:\Documents and Settings\Username\My Documents"
  rsPictures.MoveNext

Wend

See Also