Access save an OLE Object from the database to a file RRS feed

  • Question

  • I've inherited an old Access system that is maxed out on attachment fields in several tables.  I am trying to use the routine for Access 2010 to extract the attached OLE Objects and save them to a file.  All of the attachments are a single PDF per database row.  

    The routine I am attempting to use is from the Microsoft Access 2010 example.  The only changes being the function name to distinguish it from my other attempts, my table name, and my field name.  The routing can be found here:


    I have pasted the beginning of it to the line where I get the error.  What I get is "runtime error 424 Object required"

    I'm no an Access or VBA guru so any help is greatly appreciated.

    Public Function SaveAttachments711(strPath As String, Optional strPattern As String = "*.*") As Long
            Dim dbs As DAO.Database
            Dim rst As DAO.Recordset2
            Dim rsA As DAO.Recordset2
            Dim fld As DAO.Field2
            Dim strFullPath As String
            'Get the database, recordset, and attachment field
            Set dbs = CurrentDb
            Set rst = dbs.OpenRecordset("targets")
            Set fld = rst("image")
            'Navigate through the table
            Do While Not rst.EOF
                'Get the recordset for the Attachments field
                Set rsA = fld.Value

    • Edited by A.J. Urso Friday, July 12, 2019 8:30 AM
    Thursday, July 11, 2019 6:46 PM

All replies

  • If you debug the error, which line is highlighted as problematic?

    Daniel Pineault, 2010-2018 Microsoft MVP
    Professional Support: http://www.cardaconsultants.com
    MS Access Tips and Code Samples: http://www.devhut.net

    Thursday, July 11, 2019 6:54 PM
  • ciao A.J.Urso,

    get a look at this demo :



    Ciao, Sandro.

    Friday, July 12, 2019 5:36 AM
  • Thank you.

    That demo worked on the demo database and allowed me to see the difference.

    The demo database has a field type of "attachment" the database I have has a field type of "OLE Object" that contains a single PDF.

    The routine fails on the same statement so there must be something different to saving an OLE Object rather than the standard attachment 

    I will have to fix my question to indicate an OLE Object

    Friday, July 12, 2019 8:28 AM