问题描述
我正在尝试将以下内容作为MS Access查询中的条件.基本上我想做的是:
I'm trying to run the following as criteria in an MS access query. Basically what I want to do is:
- 如果checkbox = True,则显示所有记录,包括具有空白或空字段的记录(我的表单组合框[combo9]中的默认值为"*")
- 如果checkbox = False,则仅显示与Combo9中的值匹配的记录
我当前的表达式没有给出任何错误,但是也没有产生任何结果!表达式的TRUE和FALSE一半可以单独工作,但结合到iif表达式中则不能工作.
My current expression doesn't give any errors, but also doesn't produce any results! The TRUE and FALSE halves of the expression work fine on their own, but don't work when combined into the iif expression.
Like IIf([Forms]![F_leg_reg]![Check25]=True,Like [Forms]![F_leg_reg]![Combo9] Or "" Or Is Null,Like [Forms]![F_leg_reg]![Combo9])
有人可以告诉我我在做什么错吗?预先感谢.
Can someone please tell me what I'm doing wrong here? Thanks in advance.
推荐答案
不确定您是否需要太多likes
,您在返回值中使用了or
逻辑运算符
Not sure you need so many likes
, you are using the or
logical operator in the return value which doesn't make sense
IIF (condition, value-if-true, value-if-false)
所以..
Like IIF ([forms]![foo].[text1] = "1" OR [forms]![foo].[text2] = "1", 'bar', 'foobar')
如果满足任一条件,则IIF将返回"bar",否则将返回"foobar"
if either conditions are met IIF will return 'bar' else it will return 'foobar'
如果需要,可以嵌套它
Like IIF ([forms]![foo].[text1] = "1" OR [forms]![foo].[text2] = "1", 'bar',
IIF ([forms]![foo].[text1] = "2" AND [forms]![foo].[text2] = "2", 'foobar', null)
)
如果满足任一条件,则IIF将返回'bar',否则我们检查text1
和和text2
是否为"2",如果这样,则返回'foobar',否则我们返回null
if either conditions are met IIF will return 'bar' else we check to see if text1
and text2
are "2" if so return 'foobar' else we return null
希望这会有所帮助
这篇关于使用OR运算符的IIF查询不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!