Excel 如果数据在sql中存在,则消息框数据存在,否则插入数据
我正在尝试插入数据,但它已存在于数据库中,然后它应向msgbox提供它已存在但不存在的数据,然后插入,您可以使用DcountExcel 如果数据在sql中存在,则消息框数据存在,否则插入数据,excel,vba,Excel,Vba,我正在尝试插入数据,但它已存在于数据库中,然后它应向msgbox提供它已存在但不存在的数据,然后插入,您可以使用Dcount If Dcount("*", "test", "ID= " & ID ) = 0 Then str = "INSERT INTO test(id) " & _ " VALUES (" & id & ") Db.Execute str Else MsgBox "Data already exi
If Dcount("*", "test", "ID= " & ID ) = 0 Then
str = "INSERT INTO test(id) " & _
" VALUES (" & id & ")
Db.Execute str
Else
MsgBox "Data already exists in the table."
End If