Excute 和 RunSql 在ACCESS中都可以用来执行SQL语句,前者执行SQL语句不会出现提示,后者则需要借助DoCmd.SetWarnings
False来关闭系统提示,除此之外,两者在书写语法上还是有一点区别
RunSql下面2种书写方式都能执行, 而Execute只能采用方法2
方法1:
Sql = "INSERT INTO SupplyRate ( PartNumber )" _
& "
SELECT SupplierPartNum.PartNumer" _
& " FROM SupplierPartNum" _
& " WHERE SupplierPartNum.PartNumer Not In (select SupplyRate.PartNumber
from SupplyRate) AND SupplierPartNum.Technology=[Forms]![FrmSupplyRate]![CmbTechnology]"
方法2:
Sql = "INSERT INTO SupplyRate (
PartNumber )" _
& " SELECT SupplierPartNum.PartNumer" _
& " FROM SupplierPartNum" _
& " WHERE
SupplierPartNum.PartNumer Not In (select SupplyRate.PartNumber from SupplyRate)
AND SupplierPartNum.Technology='" & [Forms]![FrmSupplyRate]![CmbTechnology]
& "'"