我試圖將名爲New_ParcelNum
的字段更新爲FLAG
,具體取決於字母字符是否位於字符串中。訪問SQL。檢測字符串中的字母字符
'FLAG anything with a letter.
sql_UpdateNew = "DECLARE @Counter INT;" & _
"SET @Counter = ASCII('A');" & _
"WHILE Counter <= ASCII('Z') " & _
"BEGIN" & _
"IIF(INSTR(tblParcelNumber, CHAR(@Counter)) > 0, " & _
"UPDATE tblParcelNumber SET tblParcelNumber.New_ParcelNum = 'FLAG', " & _
"tblParcelNumber.New_ParcelNum);" & _
"SET @Counter = @ Counter + 1;" & _
"END;"
DoCmd.RunSQL sql_UpdateNew
我不斷收到一個運行時錯誤:
(3129), invalid SQL statement. Expected DELETE, INSERT, PROCEDURE, SELECT, UPDATE.