你好,我有這個疑問:錯誤VBA
strSQL = "SELECT DATEPART(yyyy,ArriveDate) AS God," & _
"COUNT (CASE DATEPART(d,ArriveDate) WHEN 1 THEN DATEPART(d,ArriveDate) END)As m1 ," & _
"COUNT (CASE DATEPART(d,ArriveDate) WHEN 2 THEN DATEPART(d,ArriveDate) END)As m2 ," & _
"COUNT (CASE DATEPART(d,ArriveDate) WHEN 3 THEN DATEPART(d,ArriveDate) END)As m3 ," & _
"COUNT (CASE DATEPART(d,ArriveDate) WHEN 4 THEN DATEPART(d,ArriveDate) END)As m4 " & _
" FROM Company " & _
" WHERE DATEPART(yyyy,ArriveDate) =" & [Forms]![Raport_lunar_anual_carnete]![ANUL] & _
" AND DATEPART(mm,ArriveDate)= " & [Forms]![Raport_lunar_anual_carnete]![LUNA] & _
" GROUP BY DATEPART(yyyy,ArriveDate)"
它說我說:關鍵字附近不正確的語法 「和」
也許嘗試刪除這部分中的逗號(',')作爲m4,'成爲'm4'。這會觸發SQL服務器的錯誤,不確定有關ms訪問 – har07
我刪除它,也試試這個eror – Sergio
調試,在上面的代碼後面加上break point,並看到'strSQL'字符串輸出。如果您在查看後沒有想法,請張貼字符串。 – har07