【发布时间】:2013-07-12 22:05:08
【问题描述】:
我有一个表单,可以按用户、日期范围和列的特定值过滤数据,具体取决于是否勾选了复选框,如下所示;
strWhere = " WHERE [user] in (" & Left(strIN, Len(strIN) - 1) & ") And [Month] Between [forms]![frm_user]![txtStartDate] And [forms]![frm_user]![txtEndDate]"
If Me!checkbox = True Then
strtcheck = " (Satified Vs Dissatisfied Like Dissatisfied) "
End If
strSql = strSql & strwhere & strtcheck
所以我想要但我无法让它工作的是,如果 Me!checkbox 为真,那么 Satified Vs Dissatisfied 必须等于 Dissatisfied,然后我想将它传递给 strSql,但是当我运行时在Access中它不起作用,有人可以帮忙吗?
【问题讨论】:
-
合成的 where 子句中似乎缺少一些引号。试试
strWhere = " WHERE [user] in ('" & Left(strIN, Len(strIN) - 1) & "') And [Month] Between [forms]![frm_user]![txtStartDate] And [forms]![frm_user]![txtEndDate]"。strtcheck中的Vs运算符是什么意思?Satisfied、Dissatisfied是表属性、表单属性还是文字?like运算符仅在与 sql 通配符 (%) 一起使用时才有意义。如果您将strtcheck附加到部分 where 子句,则您忘记了运算符 (AND?)。strIN的内容是什么?。 -
“满意与不满意”列的名称
-
好的,刚刚在 hansup 的回答中看到了(在 where 子句的第一部分加上单引号应该可以解决问题)。