Option Explicit
Private Sub Form_Load()
Dim conn As ADODB.Connection
Dim WN As String
Dim OldTableName As String
Dim NewTableName As String
Dim sSql As String
Dim tStr As String
Dim conn As ADODB.Connection
Dim WN As String
Dim OldTableName As String
Dim NewTableName As String
Dim sSql As String
Dim tStr As String
WN = "db_sell.mdb"
OldTableName = "经手人表"
NewTableName = "test"
tStr = "钢笔"
OldTableName = "经手人表"
NewTableName = "test"
tStr = "钢笔"
Set conn = New ADODB.Connection
conn.ConnectionString = "Provider=Microsoft.Jet.Oledb.4.0;" & _
"Data Source=C:\" & WN
conn.Open
If conn.State = adStateOpen Then
sSql = "Insert Into " & NewTableName & " Select * From " & OldTableName & " "
conn.Execute sSql
MsgBox "成功把“" & OldTableName & "”中的所有的“" & tStr & "”记录汇总到“" & NewTableName & "”中!", , " http://excelba.com"
conn.Close
End If
Set conn = Nothing
conn.ConnectionString = "Provider=Microsoft.Jet.Oledb.4.0;" & _
"Data Source=C:\" & WN
conn.Open
If conn.State = adStateOpen Then
sSql = "Insert Into " & NewTableName & " Select * From " & OldTableName & " "
conn.Execute sSql
MsgBox "成功把“" & OldTableName & "”中的所有的“" & tStr & "”记录汇总到“" & NewTableName & "”中!", , " http://excelba.com"
conn.Close
End If
Set conn = Nothing
End Sub
本文转自9pc9com博客,原文链接: http://blog.51cto.com/215363/744997
如需转载请自行联系原作者