我有以下ms访问查询。我希望它使用从组合框中选择的性别(女性或男性)进行查询。目前,当我选择"女性"时,查询结果还包括所有男性。
我应该如何设置此代码的格式:
WHERE (((Q_Gender_Statistics.Year) Like [cboYear] & "*") AND ((Q_Gender_Statistics.Gender) Like "*" & [cboGender] & "*"))
答案 0 :(得分:-1)
如果不需要,请不要使用Like:
" WHERE Q_Gender_Statistics.Year = " & [cboYear] & " AND Q_Gender_Statistics.Gender = '" & [cboGender] & "'"
如果cboGender查找“男/女”形成索引值,请尝试:
" WHERE Q_Gender_Statistics.Year = " & [cboYear] & " AND Q_Gender_Statistics.Gender = " & [cboGender] & ""