Need to convert from embedded documents to linked documents

Richard Cruthirds 61 Reputation points
2021-09-27T13:57:27.317+00:00

I made a rookie mistake by embedding documents into a table instead of linking them. . . luckily, the documents are still in the same location that they were embedded from . . .does anyone have any VBA code that will run through the table and either build another table or add a field in the same table with the filename link so I can delete the embedded documents and revert to a link?

Access Development
Access Development
Access: A family of Microsoft relational database management systems designed for ease of use.Development: The process of researching, productizing, and refining new or existing technologies.
817 questions
0 comments No comments
{count} votes

Accepted answer
  1. DBG 2,301 Reputation points
    2021-09-27T18:54:27.8+00:00

    Okay, I just did a quick test by adding an Attachment field to a table and then running this code. It printed all the filenames I added to the table.

    Public Function ListAttachments() As Boolean
    'thedbguy@gmail.com
    '9/27/2021
    
    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Dim rs2 As DAO.Recordset2
    
    Set db = CurrentDb()
    Set rs = db.OpenRecordset("Table1")
    
    With rs
        Do While Not .EOF
            Set rs2 = !docs.Value
            Do While Not rs2.EOF
                Debug.Print rs2.FileName
                rs2.MoveNext
            Loop
            rs2.Close
            .MoveNext
        Loop
        .Close
    End With
    
    Set rs2 = Nothing
    Set rs = Nothing
    Set db = Nothing
    
    End Function
    

    Hope that helps...

    0 comments No comments

6 additional answers

Sort by: Most helpful
  1. DBG 2,301 Reputation points
    2021-09-27T16:21:07.527+00:00

    Hi. How many records/documents are we talking about? Is there too much to do it manually?

    0 comments No comments

  2. Richard Cruthirds 61 Reputation points
    2021-09-27T18:24:28.567+00:00

    Yes . . .almost 5,000 records

    0 comments No comments

  3. DBG 2,301 Reputation points
    2021-09-27T18:27:35.887+00:00

    Hi. Thanks for the clarification. One more question: Are we talking about an Attachment field or OLE Object?

    0 comments No comments

  4. Richard Cruthirds 61 Reputation points
    2021-09-27T18:52:18.02+00:00

    It's an Attachment field

    0 comments No comments