运行-时间错误3075语法错误

run-time error 3075 syntax error

今天早上我一直在为这个 NUMBER(在 Table 中列出)语法苦苦挣扎 - 我有一个带有组合框 [cboIndicator] 的表单,它从 [=18] 中查找值 [Severity Indicator] =] 称为 tbl_ASPACSplitInventorySelect。现在严重性指标 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 语法错误。如您所知,列出了一个子表单并仔细检查了所有源对象。任何帮助将不胜感激。第四行似乎因数据不匹配而突出显示。

在声明中

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

缺少引号和“)”。

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

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

如果 table 字段 Severity Indicator 定义为 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 ...