我在查询表达式中遇到错误“语法错误(缺少运算符)”:

'tblFICL.Product = Muni/Money Market AND tblFICL.Broker_Code = WELLS'

完整的vba查询如下。我猜想这与我的变量prdctbkr有关。我在此查询中缺少什么语法?
'Set and Excecute SQL Command'
strSQL = "SELECT tblFICL.Email " _
    & " FROM tblFICL " _
    & " WHERE tblFICL.Product = " & prdct & " AND tblFICL.Broker_Code = " & bkr & ""

整天都在注视着,任何帮助都会得到极大的帮助。

最佳答案

您可能需要在值前后加上撇号。尝试下面的代码

strSQL = "SELECT tblFICL.Email " _
    & " FROM tblFICL " _
    & " WHERE tblFICL.Product = '" & prdct & "' AND tblFICL.Broker_Code = '" & bkr & "'"

关于excel - Excel VBA中的语法错误(缺少运算符),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/17842928/

10-12 18:18