SQL行抛出错误3134(插入语法)

时间:2018-08-03 15:14:24

标签: sql vba ms-access access-vba

我已经浏览过类似的文章,还无法在这里找出导致我的错误的确切原因。据我所知,我的语法是正确的,并且包含了构建代码,该构建代码可以正常运行直到执行SQL行。

rs.MoveFirst
If Me.chkBBB = True Then
Do Until rs.EOF
    strBBB = rs!BBB
    strBrktDet1 = Left(strBBB, 2)
    strBrktDet2 = Right(strBBB, 8)
    If strBrktDet1 = "99" Then varBracket = -1
    If strBrktDet1 = "98" Then varBracket = 0
    strBPINo = Nz(DLookup("[BPINo]", "[Caliper Master]", "[BBB] LIKE" & "'*" & strBrktDet2 & "'"), "N/A")
    strCentric = Nz(DLookup("[CentricItemNo]", "[Caliper Master]", "[BBB] LIKE" & "'*" & strBrktDet2 & "'"), "N/A")
    strCardoneNo = Nz(DLookup("[A1CardoneItemNo]", "[Caliper Master]", "[BBB] LIKE" & "'*" & strBrktDet2 & "'"), "N/A")
    If strBPINo = "" Or Null Then strBPINo = "N/A"
    intQty = rs!Need
    strSQL = "INSERT INTO tblCaliperOrderDetails (OrderNumber, Cardone, BBB, BPI, Centric, WithBracket, QuantityNd) VALUE(" & lngOrderNo & ", '" & strCardoneNo & "', '" & strBBB & "', '" & strBPINo & "', '" & strCentric & "', '" & varBracket & "', " & intQty & ")"
    Debug.Print strSQL
    DoCmd.RunSQL strSQL
    rs.MoveNext
Loop

立即窗口返回

INSERT INTO tblCaliperOrderDetails (OrderNumber, Cardone, BBB, BPI, Centric, WithBracket, QuantityNd) VALUE(18190059, 'N/A', '99-00644L-C', 'N/A', '42172', '-1', 208)

订单号,QuantityNd是数字字段,所有其他字段是文本字段,WithBracket是三态复选框的控制源。

据我所知,一切正常,在线SQL检查器告诉我我的语法是正确的,而且我整天都在处理这个问题,所以我想问清楚眼睛和头脑。 / p>

1 个答案:

答案 0 :(得分:5)

SQL关键字是“ VALUES”而不是“ VALUE”