Private Sub copydata(strtb As String)' copy data from cmsdb to cmserrdb
Dim db As DAO.Database
Dim tb As DAO.TableDef
Dim tf As DAO.Field
Dim strtype As String
Dim str As String
Dim strsql As String
Dim strsize As String
Dim rs1 As ADODB.Recordset
Dim i As Long
Dim j As Integer
Set rs1 = New ADODB.Recordset
Dim rs2 As ADODB.Recordset
Set rs2 = New ADODB.Recordset
If conCMSERR Is Nothing Then
Set conCMSERR = New ADODB.Connection
conCMSERR.Open strDestErrDB
End If
If conCmsDB Is Nothing Then
Set conCmsDB = New ADODB.Connection
conCmsDB.Open strDestDB
End If
rs1.Open "select * from " & strtb, conCMSERR, adOpenDynamic, adLockBatchOptimistic, adCmdText
rs2.Open "select * from " & strtb, conCmsDB, adOpenKeyset, adLockReadOnly, adCmdText
If Not rs2.BOF Then
rs2.MoveLast
rs2.MoveFirst
For i = 1 To rs2.RecordCount
rs1.AddNew
For j = 0 To rs2.Fields.Count - 1
If UCase(rs1.Fields(j).name) = UCase(rs2.Fields(j).name) Then
rs1.Fields(j).Value = rs2.Fields(j).Value
End If
Next
rs1.UpdateBatch
rs2.MoveNext
Next
End If
conCMSERR.Close
conCmsDB.Close
Set rs1 = Nothing
Set rs2 = Nothing
Set conCMSERR = Nothing
Set conCmsDB = Nothing
End Sub