我试图让我的代码在另一个表的ID值是偶数时更新我的​​验证表中的一列,但我不断收到语法错误,并且从网上看到的所有示例ive可以看出,它是正确的(显然不是,但看起来不错)。语法错误被抛出到代码的where语句部分,有人看到我看不到的东西吗?

DoCmd.RunSQL "UPDATE OTCValidation LEFT JOIN Option16 ON Option16.[Plan Code]=OTCValidation.[Plan Code] SET OTCValidation.[Step 1 Actual]= Option16.[RXOTCIND] WHERE Option16.ID % 2 = 0 AND OTCValidation.[Plan Code] is not Null"
DoCmd.RunSQL "UPDATE OTCValidation LEFT JOIN Option16 ON Option16.[Plan Code]=OTCValidation.[Plan Code] SET OTCValidation.[Step 2 Actual]= Option16.[RXOTCIND] WHERE Option16.ID % 2 <> 0 AND OTCValidation.[Plan Code] is not Null"

最佳答案

Access使用Mod关键字作为模运算符。

DoCmd.RunSQL "UPDATE OTCValidation LEFT JOIN Option16 ON Option16.[Plan Code]=OTCValidation.[Plan Code] SET OTCValidation.[Step 1 Actual]= Option16.[RXOTCIND] WHERE Option16.ID Mod 2 = 0 AND OTCValidation.[Plan Code] is not Null"
DoCmd.RunSQL "UPDATE OTCValidation LEFT JOIN Option16 ON Option16.[Plan Code]=OTCValidation.[Plan Code] SET OTCValidation.[Step 2 Actual]= Option16.[RXOTCIND] WHERE Option16.ID Mod 2 <> 0 AND OTCValidation.[Plan Code] is not Null"

关于sql - 使用余数在ms Access 中设置字段值,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23273145/

10-11 01:54