0
공용 함수 및 쿼리가있는 MS Access 데이터베이스가 있습니다. 함수가 'Attachments'열의 모든 필드를 반복하여 그 필드의 모든 첨부 파일을 저장하고 싶습니다. "SEDOL"열과 해당 행 값을 파일 이름의 첫 번째 부분으로 저장해야하지만 아래 코드의 "Set rsA2 = fld2.Value"행에 도청이 계속됩니다. SEDOL 열은 일반적인 텍스트 필드 열입니다. 코드는 SEDOL 저장 이름 부분없이 작동합니다. 나는 그것이 작동하도록하는 방법에 대한 몇 가지 제안을 좋아한다. 감사합니다함수 및 쿼리를 사용하여 액세스에서 첨부 파일 저장
Public Function SaveAttachments(strPath As String, Optional strPattern As String = "*.*") As Long
Dim dbs As DAO.Database
Dim rst As DAO.Recordset2
Dim rst2 As DAO.Recordset2
Dim rsA As DAO.Recordset2
Dim rsA2 As DAO.Recordset2
Dim fld As DAO.Field2
Dim fld2 As DAO.Field2
Dim strFullPath As String
'Get the database, recordset, and attachment field
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("Core Securities")
Set fld = rst("Attachments")
Set fld2 = rst("SEDOL")
'Navigate through the table
Do While Not rst.EOF
'Get the recordset for the Attachments field
Set rsA = fld.Value
'BUGS IN NEXT LINE
Set rsA2 = fld2.Value
'Save all attachments in the field (works without rsA2)
Do While Not rsA.EOF
If rsA("FileName") Like strPattern Then
strFullPath = strPath & "\" & rsA2("SEDOL") & " - " & rsA("FileName")
'Make sure the file does not exist and save
If Dir(strFullPath) = "" Then
rsA("FileData").SaveToFile strFullPath
End If
'Increment the number of files saved
SaveAttachments = SaveAttachments + 1
End If
'Next attachment
rsA.MoveNext
Loop
rsA.Close
'Next record
rst.MoveNext
Loop
rst.Close
dbs.Close
Set fld = Nothing
Set rsA = Nothing
Set rst = Nothing
Set dbs = Nothing
End Function
매우 감사 버그의 행동을 유발했다 수많은 이상한 일을 제거했습니다 : 그것은 가치의에
그냥 참조 – chandu