嵌套的IF语句返回false [英] Nested IF statement returning false

查看:153
本文介绍了嵌套的IF语句返回false的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个嵌套的if语句返回"False",而不是预期的结果.

I have a nested if statement is returning "False" rather than the expected outcome.

场景

高压电缆"表中的数据默认为数字,但可能包含以下字符: kVa

Table "High VoltageCables" has data in it that default to numeric but may contain characters: kVa

表主"将高压电缆"数据检查为空白还是不为空白,并返回检查失败1",通过检查1".效果很好.

Table "Master" checks "High VoltageCables" data as blank or not blank, and returns "Failed Check 1","Passed Check 1". This works fine.

然后,表"Meta"检查"Master"的结果,然后测试"High VoltageCables"数据的长度在1到6之间.无论记录是数字还是字符串.

Table "Meta" then checks the results of "Master" and then tests "High VoltageCables" data for length between 1 and 6, regardless of whether record is numeric or string.

公式

=IF(MASTER!H2="Passed Check 1",IF(LEN('High VoltageCables'!O2)>=1,IF(LEN('High VoltageCables'!O2<6),"Passed Check 2","Failed Check 2")))

部分成功,因为它在源表"High VoltageCables"中为以下示例数据返回"Passed Check 2".

This is partially succesful, as it returns "Passed Check 2" for the following sample data in the source table "High VoltageCables".

1个数字

1kVa str,

50000 数字

但是,如果高压电缆"中的字段为空白,则公式将返回"FALSE",而不是"Failed Check 1"

However if a field in "High VoltageCables"is blank, the formula returns "FALSE" rather than "Failed Check 1"

我继承了此任务,(并且本来希望使用相对简单的查询在Access中完成全部操作)-不幸的是,我不熟悉嵌套的If语句,因此我可能缺少一些基本的知识...

I inherited this task, (and would have preferred to do the whole thing in Access using relatively simple queries) - and unfortunately I am new to nested If statements, so I am probably missing something basic...

请注意,高压电缆中的数据必须默认为数字,以便进一步检查.

NB the data in High VoltageCables must default to numeric for a further check to work.

推荐答案

第一个和第二个IF似乎缺少了else部分.应该在)))末尾之间添加它们,例如),else),else)如果您有两个嵌套的ifs,则每个IF语句均由IF(condition,truepart,falsepart)组成,它将类似于IF(condition,IF(condition2,truepart2,falsepart2),falsepart)希望可以使它更清晰

The first and second IF's seem to be missing the else part. They should be added at the end between the ))) like ), else ), else ) Every IF statement consists of IF( condition, truepart, falsepart) if you have two nested ifs it will be something like IF( condition, IF( condition2, truepart2, falsepart2), falsepart) Hope that makes it a little clearer

这篇关于嵌套的IF语句返回false的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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