gpt4 book ai didi

sql - 基于多个字段选择数据(Where And)

转载 作者:行者123 更新时间:2023-12-04 15:59:54 24 4
gpt4 key购买 nike

我有大量数据,我正试图根据两个级联组合框来整理这些数据。我收到错误 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应该为此工作。导致此错误的原因是什么,我该如何解决?

最佳答案

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 & "'"

关于sql - 基于多个字段选择数据(Where And),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13650899/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com