I would like to seek help in my update statement in ms access. I don't know if possible but can we incorporate SELECT statement in UPDATE statement?
Here's the code that I have problem.
DoCmd.RunSQL _
"UPDATE tab_lists " & _
"SET " & _
"total_calls = ((SELECT COUNT(filler3) FROM table WHERE [attempt_counter] = 5) " & _
"WHERE " & _
"listid = " & listid1 & ""
Yes, you can.
I prefer CurrentDb.Execute:
CurrentDb.Execute ("UPDATE tab_lists SET total_calls = (SELECT COUNT(filler3) AS CountFill FROM table WHERE [attempt_counter] = 5) WHERE listid = " & listid1)
However, saving aggregate data is usually a bad idea. Should just calculate when needed.
Your table is named table? That is also not good.
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.