excel导入access时怎样禁止重复数据导入
Dim sPath As String
sPath = Text1.Text
Dim db As New ADODB.Connection
db.Open "Provider=Microsoft.ace.OLEDB.12.0;Data Source=" & App.Path & "\storage.accdb" & ";Persist Security Info=False"
Call db.Execute("INSERT into 终检档案 SELECT * From [Sheet1$] In '" & sPath & "' 'excel 8.0;'")
MsgBox "导入成功", vbOKOnly, "提示"
db.Close
Set db = Nothing
以上代码这是将excel数据全部导入access中,怎样改当excel中的管号数据与access管号数据相同时提示禁止导入 Excel
[解决办法]
没有试过,不知道行不行,你试试看
Call db.Execute("INSERT into 终检档案 SELECT * From [Sheet1$] In '" & sPath & "' 'excel 8.0;' WHere [Sheet1$].[管号] not in(select 管号 from 终检档案)")