pedie
Well-known Member
- Joined
- Apr 28, 2010
- Messages
- 3,875
Hi, this work perfect within the tables in same db however the errors comes when i try to use this codes to transfer object/files attached in the records.
Please advice if there is something 'm missing...
maybe not the right connection type...or the way 'm referring to something is wrong...
Thanks in advance for helping.
OrginalLink
Please advice if there is something 'm missing...
maybe not the right connection type...or the way 'm referring to something is wrong...
Thanks in advance for helping.
OrginalLink
Code:
[/FONT]
[FONT=Courier New]Option Compare Database
Option Explicit
Sub vbxvbncvbncvbnd()
Dim strCNXN As String
Dim CNXN As New ADODB.Connection
Dim rstFrom As ADODB.Recordset
Dim rstTo As ADODB.Recordset
Dim rstMVF As ADODB.Recordset
Dim rstMVT As ADODB.Recordset[/FONT]
[FONT=Courier New]Set CNXN = New ADODB.Connection
strCNXN = "Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=E:\TestDb.accbd;Uid=;Pwd=;"
CNXN.Open "Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=E:\TestDb.accbd;Uid=;Pwd=;"[/FONT]
[FONT=Courier New]Set rstFrom = New ADODB.Recordset
rstFrom.Open "a", CNXN, adOpenDynamic, adLockOptimistic[/FONT]
[FONT=Courier New]Set rstTo = New ADODB.Recordset
rstTo.Open "b", CurrentProject.Connection, adOpenDynamic, adLockOptimistic[/FONT]
[FONT=Courier New]Do While rstFrom.EOF = False
rstTo.AddNew
rstTo!CLIENTIDS = rstFrom![CLIENTIDS]
[COLOR=teal][I][U]Set rstMVF = rstFrom!Attachments.Value
[/U][/I][/COLOR]Set rstMVT = rstTo!Attachments.Value
Do While rstMVF.EOF = False
rstMVT.AddNew
rstMVT!FileData = rstMVF!FileData
rstMVT!FileFlags = rstMVF!FileFlags
rstMVT!FileName = rstMVF!FileName
rstMVT!FileTimeStamp = rstMVF!FileTimeStamp
rstMVT!FileType = rstMVF!FileType
rstMVT!FileURL = rstMVF!FileURL
rstMVT.Update
rstMVF.MoveNext
Loop[/FONT]
[FONT=Courier New]Set rstMVF = Nothing
Set rstMVT = Nothing
rstTo.Update[/FONT]
[FONT=Courier New]rstFrom.MoveNext
Loop[/FONT]
[FONT=Courier New]rstFrom.Close
rstTo.Close[/FONT]
[FONT=Courier New]CNXN.Close
Set CNXN = Nothing
End Sub