简体   繁体   English

访问查询条件“如果选项3,则返回null”

[英]Access query criteria “If Option 3, return null”

I have an Access query that looks at a Form to see which of 3 radio buttons (in a group called frmStatus) is selected. 我有一个访问查询,该查询查看一个窗体以查看选择了3个单选按钮(在名为frmStatus的组中)中的哪个。 If the first is selected, the IIF returns "True", and if the second is selected, it returns "False", but if the third is selected, I want the IIF to return absolutely nothing so the criteria is, in effect, empty. 如果选择了第一个,则IIF返回“ True”,如果选择了第二个,则IIF返回“ False”,但是如果选择了第三个,我希望IIF绝对不返回任何值,因此该条件实际上为空。

Right now, this is my criteria: 现在,这是我的标准:

IIf([Forms]![SP_Search_Criteria]![frmStatus]=3,Like "*",IIf([Forms]![SP_Search_Criteria]![frmStatus]=1,True,False))

With the SQL for that (Disregard the Date() part -- that's for searching by age): 使用该SQL(忽略Date()部分-用于按年龄搜索):

WHERE ((((Date()-[DoB])/365.25)>=[Forms]![SP_Search_Criteria]![txtMinAge] And ((Date()-[DoB])/365.25)<[Forms]![SP_Search_Criteria]![txtMaxAge]) AND ((StandardizedPatients.Active)=IIf([Forms]![SP_Search_Criteria]![frmStatus]=3,(StandardizedPatients.Active) Like "*",IIf([Forms]![SP_Search_Criteria]![frmStatus]=1,True,False))))

Options 1 and 2 work just fine... I can't seem to get Option 3 to work at all. 选项1和2可以正常工作...我似乎根本无法使选项3正常工作。

So, my question is this: What can I put in an IIF inside a Query Criteria to effectively search without a criteria? 因此,我的问题是: 我可以在查询条件内的IIF中放入什么内容,以在没有条件的情况下有效地进行搜索?

我可以正常工作-我所做的只是删除了“ Like“ *””部分,所以现在WHERE看起来像这样:

WHERE ((((Date()-[DoB])/365.25)>=[Forms]![SP_Search_Criteria]![txtMinAge] And ((Date()-[DoB])/365.25)<[Forms]![SP_Search_Criteria]![txtMaxAge]) AND ((StandardizedPatients.Active)=IIf([Forms]![SP_Search_Criteria]![frmStatus]=3,(StandardizedPatients.Active),IIf([Forms]![SP_Search_Criteria]![frmStatus]=1,True,False))))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM