我有一个表单按用户,日期范围和列的特定值过滤数据,具体取决于是否选中了复选框,如下所示;
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
所以我想要的是我无法让它工作,如果我!复选框为真,那么不满意的不满意必须等于不满意然后我想将它传递给strSql,但是当我运行时它在Access中不起作用,有人可以帮忙吗?
答案 0 :(得分:1)
如果您的字符串旨在为名为 Satified Vs Dissatisfied 的字段包含WHERE
条件,请将字段名称括在方括号中。并将您比较的字符串括在引号中的字段中。
strtcheck = " ([Satified Vs Dissatisfied] Like 'Dissatisfied') "
实际上该条件不使用模式匹配,因此您只能使用=
代替Like
。
strtcheck = " ([Satified Vs Dissatisfied] = 'Dissatisfied') "
此外,您可能需要包含SQL AND
以将该条件与其他WHERE
条件相结合。
strtcheck = " AND ([Satified Vs Dissatisfied] = 'Dissatisfied') "