i am trying to have my code update a column in my validation table when the ID value in another table is even but i keep getting a syntax error, and from what i can tell from all the examples ive seen online its right (apparently not, but it looks right). The syntax error gets thrown on the where statement part of the code, does anyone see something that I dont?

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 uses the Mod keyword as the modulus operator.

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"
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top