我尝试使用多个组合框选项来过滤最终组合框中显示的记录。如果我使用Select Where,它工作正常,但只要我在语句中添加AND,它就不会返回任何记录。我没有收到任何错误。只是没有结果并且已经验证了结果应该填充。现在,我已经删除了组合框变量(me.combobox.value),我将值正确地放入代码中以简化并尝试使其工作(例如通用电气和第1阶段涡轮叶片)。第一个代码集只能使用WHERE子句。第二个不起作用因为我插入了一个AND子句。谁能告诉我为什么这不会返回结果?
Private Sub cboConfiguration_AfterUpdate()
On Error Resume Next
Dim strSQL As String
Dim strComponent As String
Dim strOEM As String
Dim strScope As String
Dim strConfig As String
strScope = Me!cboScope.Value
strConfig = Me!cboConfiguration.Value
'this one will work
'strSQL = "SELECT * FROM MASTER_WORKSCOPES " & _
"WHERE OEM = " & " 'General Electric'"
'this one returns no results
'strSQL = "SELECT * FROM MASTER_WORKSCOPES " & _
"WHERE OEM = " & " 'General Electric' AND Components = " & " 'Stage 1 Turbine Blade'"
Me.cboTables.RowSourceType = "Table/Query"
Me.cboTables.RowSource = strSQL
Me.cboTables.Requery
Me.cboTables.Enabled = True
Me.cboTables.SetFocus
Me.cboTables.Dropdown
End Sub
答案 0 :(得分:0)
如果您尝试将AND关键字更改为OR,该怎么办?我的预感是,没有任何行同时具有与这些值相等的两列。您的动态SQL似乎没有任何问题。