简体   繁体   English

语法错误MS Access SQL

[英]Syntax Error MS Access SQL

I'm stuck on this SQL, it is saying that I am missing an operator and highlighting "Available" . 我坚持使用此SQL,这是说我缺少一个运算符,并突出显示了"Available" What I am trying to do is create this Update query in VBA, I need the field [TS] to update but only if the [Status] is "Available". 我想做的是在VBA中创建此更新查询,我需要字段[TS]进行更新,但前提是[Status]为“可用”。 Here's the full code below: 以下是完整的代码:

UPDATE attendance SET TS = " & iif [Status] = "Available" Then DMax("[TS]", "attendance") + 1 & " WHERE [userID]= " & rs!userID

I'm thinking I may not have this statement in the correct order. 我想我可能没有正确的顺序来执行此语句。

"IIF" is a function that expects three parameters (wrapped in parenthesis), and returns either the true-result or the false-result depending on the value of the condition, like this: iif(condition, true-result, false-result). “ IIF”是一个需要三个参数(用括号括起来)的函数,并根据条件的值返回true结果或false结果,例如:iif(condition,true-result,false-result )。

But, even if you fixed that syntax error in your query, I don't think your query would do what you are hoping for. 但是,即使您在查询中修复了该语法错误,我也不认为您的查询会满足您的期望。 Maybe something like this would work better: 也许这样会更好:

"UPDATE attendance SET [TS]= [TS]+1 WHERE [userID]=" & rs!userID & " AND [Status]=""Available"""

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM