一张有大约300张带照片附件字段的记录的表格,我需要将这300条记录复制到另一张表格。
以下功能将调用300次。
Private Sub copyAttachmentField(ByRef srcField As DAO.Field, ByRef expField As DAO.Field)
On Error GoTo Err_copyAttachmentField
Dim rsSrcAtt As DAO.Recordset
Dim rsExpAtt As DAO.Recordset
Set rsSrcAtt = srcField.Value
Set rsExpAtt = expField.Value
If Not (rsSrcAtt.BOF And rsSrcAtt.EOF) Then
rsSrcAtt.MoveFirst
Do While Not rsSrcAtt.EOF
rsExpAtt.AddNew
rsExpAtt.fields("filedata").Value = rsSrcAtt.fields("filedata").Value <==== THIS I REMARK IT TO DEBUG
rsExpAtt.fields("filename").Value = rsSrcAtt.fields("filename").Value
rsExpAtt.Update
rsSrcAtt.MoveNext
Loop
End If
rsSrcAtt.Close
rsExpAtt.Close
Set rsSrcAtt = Nothing
Set rsExpAtt = Nothing
Exit Sub
Err_copyAttachmentField:
If Err.Number = 3420 Then
rsSrcAtt.Close
rsExpAtt.Close
Set rsSrcAtt = Nothing
Set rsExpAtt = Nothing
Exit Sub
Else
MsgBox Err.Number & vbCr & Err.Description
Resume
End If
End Sub
每次,accdb增长100M字节。我可以肯定这张照片非常小。它们只是50k jpg文件。所以300 * 50k = 15,000k。 (15MB)
然后我评论&#34; filedata&#34;线,它不会再增长......
答案 0 :(得分:0)
除了之后运行契约之外,没有什么可做的。
但它不会伤害或损坏任何东西,但是如果你不能忍受它,你将不得不将你的附件保存为外部单独的文件。