我的IIF声明出了什么问题: [英] What's wrong with my IIF statement:

查看:87
本文介绍了我的IIF声明出了什么问题:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好:


我试图找出IF语句的正确语法,因为无论是否存在真或假参数,我的结果都会产生错误的结果。


这是语法:
iif (条件,value_if_true,value_if_false)


这是我的拥有:

= IIf([txtDiffMatWat] = [TotBW],Good To Go,有一个错误)


目前,条件应该是真的,它应该产生好的去,然而,它产生有一个错误。我改变了它们,真假部分,然后很好地出现了。我打开表格,然后说,有一个错误。我的语法是否正确?如果是这样,为什么它会给出错误的条件值?

解决方案

@csolomon


txtDiffMatWat和TotBW的值是多少?在你的表达式中,你要问的是txtDiffMatWat是否等于TotBW。确保在更改表达之前'确实发生了什么'。


如果txtDiffMatWat = 3且TotBW = 4

那么你的表达式将是假的


如果txtDiffMatWat = 5且TotBW = 5

那么你的表达式应该评估为真。


如果满足这些条件并且它仍然无效,请回发并包含您的测试值。


在我询问的情况下,两个控件= 3115,这将评估真的。


最初,我把它设置得像我发布的格式,但是当它给出了错误的选择时,我将错误和真实的部分切换到了这个:

= IIf([txtDiffMatWat] = [TotBW],有一个错误,Good To Go)

应该匹配格式:

= IIf([txtDiffMatWat] = [TotBW],Good To Go,有一个错误)


哪个显示Good to Go when两者都是平等的。这违背了格式应该是什么。


这些可能是愚蠢的问题,但你在查询中使用这个表达式,对吧?您在表达式中引用的字段是否也在查询中?


此外,字段是否具有相同的格式/数据类型?我不知道这是否会对所有数字或所有字母产生影响,但我知道如果你试图将文本与数字匹配,你的结果会变得棘手,所以将长整数与一个字节匹配也会做同样的事情事情。


我用两个日期字段尝试你的表达,它对我来说很好......我会检查你桌子上的字段,以确保一切都在一起。

Hello:

I am trying to figure out the correct syntax for an IF statement because mine produces incorrect results no matter the placement of the true or false arguments.

Here is the syntax:
iif ( condition, value_if_true, value_if_false )

Here is what I have:
=IIf([txtDiffMatWat]=[TotBW],"Good To Go","There''s an Error")

currently, the condition should be true, which should produce "good to go", however, it produces, "there is an error". I changed them around, the true and false parts, and then good to go showed up. I opened the form and then it said, there is an error. Is my syntax correct? If so, why might it be giving the wrong value for the condition?

解决方案

@csolomon
What are the values of txtDiffMatWat and TotBW? In your expression you are asking if txtDiffMatWat is equal to TotBW. Make sure that''s really what''s going on before you change your expression.

If txtDiffMatWat = 3 and TotBW = 4
then your expression will be false

If txtDiffMatWat = 5 and TotBW = 5
then your expression should evaluate to true.

If these conditions are met and it''s still not working, post back and include your test values.


In the case I am asking about, both controls = 3115, which would evaluate to true.

Initially, I had it set up like the format I posted, but when it gave the wrong choice, I switched the false and true part to this:
=IIf([txtDiffMatWat]=[TotBW],"There''s an Error","Good To Go")
SHOULD BE TO MATCH FORMAT:
=IIf([txtDiffMatWat]=[TotBW],"Good To Go","There''s an Error")

Which shows Good to Go when both are equal. This goes against what the format says it should be.


These may be stupid questions, but you''re using this expression in a query, right? Are both the fields you refer to in the expression also in the query?

Also, are the fields the same format/data type? I don''t know if this would make a difference for all numbers or all letters, but I know your results would be screwy if you were trying to match text to number, so maybe matching a long integer with a byte would do the same thing.

I tried your expression out with two date fields and it worked just fine for me...I''d check your fields on your table to make sure everything jives together.


这篇关于我的IIF声明出了什么问题:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆