我试图检查一个表中的值与另一个表中的值,然后更新第一个表中的字段,当它们不匹配但我不能让代码工作。
到目前为止我尝试了什么;
DoCmd.RunSQL "UPDATE Issues SET Message='There is an issue at or before the sex code Field' WHERE Issues.[Sex Code] = Ref.[Sex Code] AND Ref.[Sex Code] Is Null));"
DoCmd.RunSQL "UPDATE Issues SET Message = 'There is an issue at or before the Sex Code field' LEFT JOIN Ref ON Issues.[Sex Code] = Ref.[Sex Code] WHERE ((Ref.[Sex Code]) Is Null);"
DoCmd.RunSQL "SELECT Issues.[Sex Code] FROM Issues LEFT JOIN Ref ON Issues.[Sex Code] = Ref.[Sex Code] WHERE Ref.[Sex Code] Is Null UPDATE Issues SET Message='There is an issue at or before the Sex Code Field'"
答案 0 :(得分:1)
使用您的上述想法,您需要的是以下内容,但是您确定只想加入性别代码而没有其他字段(如姓名,ID#等)?
UPDATE Issues LEFT JOIN Ref ON Issues.[Sex Code] = Ref.[Sex Code] SET Issues.Message = 'There is an issue at or before the Sex Code field'
WHERE (((Ref.[Sex Code]) Is Null));
要允许多个错误,您只需附加到“消息”字段,如下所示(保留任何先前的消息):
UPDATE Issues LEFT JOIN Ref ON Issues.[Sex Code] = Ref.[Sex Code]
SET Issues.Message = [Issues]![Message] & 'The Sex Code field is Null' & '; '
WHERE (((Ref.[Sex Code]) Is Null));