Private Sub Command1_Click()
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strSql As String
Set conn = OpenConnForAccess("test.mdb")
strSql = "insert into b select * from c"
RunTrans strSql, conn
end sub
Public Function OpenConnForAccess(ByVal FileName As String) As ADODB.Connection
Dim AdoConn As New ADODB.Connection
With AdoConn
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & FileName & ";Persist Security Info=False"
.Open
End With
Set OpenConnForAccess = AdoConn
End Function
Public Function RunTrans(ByVal tranSql As String, ByVal AdoConn As ADODB.Connection)
With AdoConn
.BeginTrans
.Execute tranSql
.CommitTrans
End With
End Function
两张表格的字段不是完全相同的
___________________________
strSql = "insert into b(id,num) select id,num from c"