简体   繁体   中英

Convert SQL Server Query to MS Access to Update Table

Could anyone help with this. I don't use Access often, but this process I'm building needs to utilize Access for the business to use. I have the following code, which will not work in Access. I keep getting the error 'Syntax Error (missing operator) in query expression'. Would anyone be able to convert this query into something Access will accept.

UPDATE Auto_DailyDiary_PrimaryTbl a
SET a.TotalDiary = sub.TotalDiary
FROM 
(
SELECT CaseEEID, Count(CaseID) as TotalDiary 
FROM dbo_Case 
WHERE CaseStatus <> 6 
GROUP BY CaseEEID
) sub
WHERE sub.EEID = a.EEID AND a.DiaryDt = Date()

Pretty sure Access doesn't like having a joined group by subquery in an update query.

Maybe try something like this?

UPDATE Auto_DailyDiary_PrimaryTbl
SET TotalDiary =
    DCOUNT('CaseID', 'dbo_Case',
        "CaseStatus <> 6 AND " &
        "CaseEEID = '" & Auto_DailyDiary_PrimaryTbl.EEID & "'")
WHERE DiaryDt = Date()

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