简体   繁体   中英

Syntax Error MS Access SQL

I'm stuck on this SQL, it is saying that I am missing an operator and highlighting "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". 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).

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"""

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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