两表之间复制问题!

pennyhe 2003-10-17 08:42:39
请问怎样可以把表t1的字段a1的全部或部分记录复制到另一表t2的b1字段呢?
...全文
46 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
xlhuo 2003-10-20
  • 打赏
  • 举报
回复
1.create a table
2.copy data to this table

give u a sample

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

zjcxc 2003-10-17
  • 打赏
  • 举报
回复
不能直接复制.
verybigmouthz 2003-10-17
  • 打赏
  • 举报
回复
什么意思 不明白
问题要讲清楚
pennyhe 2003-10-17
  • 打赏
  • 举报
回复
那么要怎样间接复制呢???

7,713

社区成员

发帖
与我相关
我的任务
社区描述
Microsoft Office Access是由微软发布的关系数据库管理系统。它结合了 MicrosoftJet Database Engine 和 图形用户界面两项特点。
社区管理员
  • Access
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧