excel vba中的语法错误(缺少运算符)

时间:2013-07-24 19:16:41

标签: excel-vba syntax-error vba excel

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

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

整天看着这一切,任何帮助都会受到极大的关注。

1 个答案:

答案 0 :(得分:4)

您可能需要在值之前和之后使用撇号。请尝试以下代码

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