4

我有大量数据试图根据两个级联组合框进行分类。我收到错误Microsoft Access can't find the field '|1' referred to in your expression,它指向我:

ElseIf [Forms]![Send To GE]![cboFil] = "LCP" Then
strSQL = "Select * From [To_GE] Where [Community] = " & Chr(34) & Me.cboSubFil.Value & Chr(34) And [LCP] = "& Chr(34) & Me.cboSSubFil.Value & Chr(34)"
Set rst = db.OpenRecordset(strSQL)    

似乎And应该为此工作。是什么导致了这个错误,我该如何解决?

4

1 回答 1

3
strSQL = "Select * From [To_GE] Where [Community] = " & Chr(34) & Me.cboSubFil.Value &     Chr(34) And [LCP] = "& Chr(34) & Me.cboSSubFil.Value & Chr(34)"

也许应该是

strSQL = "Select * From [To_GE] Where [Community] = " & Chr(34) & Me.cboSubFil.Value & Chr(34) & " And [LCP] = " & Chr(34) & Me.cboSSubFil.Value & Chr(34)

为了使事情更容易阅读,尽管我建议您在查询中转义引号或切换到单引号

strSQL = "Select * From [To_GE] Where [Community] = '" & Me.cboSubFil.Value & "' And [LCP] = '" & Me.cboSSubFil.Value & "'"
于 2012-11-30T18:47:26.707 回答