Sub a()
Dim cn As Object, Sql As String, M%
Set cn = CreateObject("ADODB.Connection")
cn.Open "provider=microsoft.ace.oledb.12.0;data source=" & ThisWorkbook.Path & "\pingzheng01.accdb"
cn.BeginTrans
Sql = "delete from BIAOZHUNPINZHENMO"
cn.Execute Sql
Sql = "INSERT INTO BIAOZHUNPINZHENMO (FDATE,FTRANSDATE,FPERIOD,FGROUP,FNUM,FENTRYID,FEXP,FACCTID,FCLSNAME1,FOBJID1,FOBJNAME1)" _
& " select F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11 " _
& "FROM [Excel 8.0;HDR=NO;DATABASE=" & ThisWorkbook.FullName & "].[sheet2$a4:K] WHERE F1 IS NOT NULL"
cn.Execute Sql, M
cn.CommitTrans
Set cn = Nothing
MsgBox "插入" & M & "条记录"
End Sub |