I've been trying to this subroutine to work... with no avail.
It says that
This is puzzling as the immediate line beforehand is the edit command that it wants????
A few things to note...
In the end, when this is working, I hope to adapt this so that the source table is a SharePoint linked table/list. (If anyone has any better solutions to achieve this goal, It would be appreciated).
The variable of 13046 is just used for testing and developing purposes in order to get this to work. Later on, i'll just declare this as a variable.
The attachments are just jpeg files so the entire field for each record is about 10MB.
Code:
Public Sub TransferAttachments()
Dim DB As Database
Dim rstSource As DAO.Recordset2
Dim rstDestination As DAO.Recordset2
Const ChunkSize = 32768
Dim Offset As Long
Dim TotalSize As Long
Dim Chunk As Variant
Dim Parameter As Variant
Offset = 0
Chunk = ""
Parameter = ""
Set DB = CurrentDb
Set rstSource = DB.OpenRecordset("Source Table", dbOpenDynaset)
Set rstDestination = DB.OpenRecordset("Secondary Table", dbOpenDynaset)
rstSource.MoveFirst
Do Until rstSource.EOF
If rstSource![ID] = 13046 Then
TotalSize = rstSource![Attachments]![FileData].FieldSize
Do While Offset < TotalSize
Chunk = rstSource![Attachments]![FileData].GetChunk(Offset, ChunkSize)
rstDestination.MoveFirst
Do Until rstDestination.EOF
If rstDestination![ID] = 13046 Then
rstDestination.Edit
rstDestination![Pictures]![FileData].AppendChunk Chunk
rstDestination.Update
End If
rstDestination.MoveNext
Loop
Offset = Offset + ChunkSize
Loop
End If
rstSource.MoveNext
Loop
End Sub
It says that
on the line that says:Rune-time error '3020': Update or CancelUpdate without AddNew or Edit'
Code:
rstDestination![Pictures]![FileData].AppendChunk Chunk
This is puzzling as the immediate line beforehand is the edit command that it wants????
A few things to note...
In the end, when this is working, I hope to adapt this so that the source table is a SharePoint linked table/list. (If anyone has any better solutions to achieve this goal, It would be appreciated).
The variable of 13046 is just used for testing and developing purposes in order to get this to work. Later on, i'll just declare this as a variable.
The attachments are just jpeg files so the entire field for each record is about 10MB.