这段代码成功了

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
WN = "db_sell.mdb"
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
End Sub

本文转自9pc9com博客,原文链接:     http://blog.51cto.com/215363/744997   如需转载请自行联系原作者

上一篇:sql excel 互导


下一篇:小打卡基于阿里云构建企业级数仓的实践及总结