运行时错误3075语法错误

时间:2016-02-03 14:08:18

标签: sql access-vba runtime-error mismatch

今天早上我一直在努力使用这个NUMBER(在表中列出)语法 - 我有一个带有组合框[cboIndicator]的表单,它从名为tbl_ASPACSplitInventorySelect的表中查找值[Severity Indicator]。现在严重性指标1-5是正确的,但组合框中的NULL值正在吐出3075错误。

Private Sub cboIndicator_AfterUpdate()
Dim myIndicator As String
myIndicator = "Select * from tbl_ASPACSplitInventorySelect where ([Severity Indicator] = '" & Me.cboIndicator
Me.ASPACSplitInventorySelect_subform1.Form.RecordSource = myIndicator
Me.ASPACSplitInventorySelect_subform1.Requery
Me.cboGrouping = Null
Me.Combo830 = Null
End Sub

我收到运行时错误3075语法错误。正如您所知,列出了一个子表单并仔细检查了所有源对象。任何帮助将不胜感激。第四行似乎是数据不匹配的突出显示。

1 个答案:

答案 0 :(得分:0)

在声明中

myIndicator = "Select * from tbl_ASPACSplitInventorySelect where ([Severity Indicator] = '" & Me.cboIndicator

报价和')'缺失。

如果表字段 Severity Indicator 定义为TEXT:

myIndicator = "Select * from tbl_ASPACSplitInventorySelect where ([Severity Indicator] = '" & cstr(Me.cboIndicator) & "');"

如果表格字段严重性指标定义为NUMBER:

myIndicator = "Select * from tbl_ASPACSplitInventorySelect where ([Severity Indicator] = " & cstr(Me.cboIndicator) & ");"

请注意,在此声明之前,检查Me.cboIndicator的值会很有用,例如:

If not isnull(Me.cboIndicator) and not isempty(Me.cboIndicator) then ...