Question

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"
Was it helpful?

Solution

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"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top