当某些字段为空时,公式将不显示 [英] Formula won't display when certain fields are null

查看:483
本文介绍了当某些字段为空时,公式将不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

与我的第一个问题类似。我要在包含以下字段的文本框中显示我的地址

  {Company} 
{AddLine1}
{AddLine2}
{ZIP} {State} {City}
{Country}

关注我的行(希望有些人)是{ZIP} {City} {State}。我想生成的是一致的寻址格式,所以即使ZIP,城市或州字段在DB中保留为空白,也不会有空格或缩进。此行应该仍然与其余行对齐,而不是缩进。我也希望在zip,状态,城市之间插入逗号,在那里他们是相关的,离开它们在哪里不。为此,我写了一个公式。下面:

 如果isnull({BILL_TO.ZIP})或trim({BILL_TO.ZIP})=Then else {BILL_TO.ZIP} 
+
(如果isnull({BILL_TO.State})或trim({BILL_TO.State})=Then
else(如果不是isnull {BILL_TO.State})
+
(如果是isnull,则为{BILL_TO.ZIP})和length(trim({BILL_TO.ZIP}))< ({BILL_TO.CATE})或长度(trim({BILL_TO.CITY}))= 0然后
else(

如果(not isnull length(trim({BILL_TO.State}))> 0)

(not isnull({BILL_TO.Zip})和length(trim({BILL_TO.Zip})) > 0)

Then,else)+ {BILL_TO.CITY}))

问题是,当只有一个城市(没有输入州或邮政编码)公式本身不会显示。然而,当其他人存在时,它显示。



任何人都可以看到此代码中的错误???



感谢您的帮助。

解决方案

为每个数据库字段创建公式字段。例如:

  // {@CITY} 
如果Isnull({BILL_TO.CITY})then

Else
Trim({BILL_TO.CITY})

// {@STATE}
如果Isnull({BILL_TO.STATE})then
Space(2)
Else
Trim({BILL_TO.STATE})

// {@ZIP}
如果Isnull({BILL_TO.ZIP})然后
空格(5)//调整以满足您的需求
Else
Trim({BILL_TO.ZIP})

在文本对象中嵌入每个公式字段。



格式化文本对象及其字段以满足您的需要。



**编辑**



我有数据质量问题,请在STATE和ZIP公式它们将是恒定长度)。我将添加逗号和间隔文本对象。


Similar to my first question. I want to show my address in a text box containing the fields as follows

{Company}
{AddLine1}
{AddLine2}
{ZIP}{State}{City} 
{Country}

The line that concerns me (and hopefully some of you guys) is {ZIP} {City} {State}. What I want to produce is a consistent addressing format, so that there will be no blank space or indentation even if a ZIP, City or State field has been left blank in the DB. This line should still line up with the rest of the rows and not be indented. I also wish to insert commas between zip, state, city where they are relevant and leave them out where not. For this I have written a formula. Below:

If isnull({BILL_TO.ZIP}) or trim({BILL_TO.ZIP})= "" Then "" else {BILL_TO.ZIP}
+
(If isnull({BILL_TO.State}) or trim({BILL_TO.State})= "" Then ""
    else(If not isnull({BILL_TO.ZIP}) and length(trim({BILL_TO.ZIP})) <> 0 Then ", "        else "") + {BILL_TO.State})
+
(If isnull({BILL_TO.CITY}) or length(trim({BILL_TO.CITY})) = 0 Then ""
    else(

            If (not isnull({BILL_TO.State}) and length(trim({BILL_TO.State})) <> 0) 
                or
                (not isnull({BILL_TO.Zip}) and length(trim({BILL_TO.Zip})) <> 0)

            Then ", " else "")+ {BILL_TO.CITY}))

The problem is that when there is only a city (no state or zip entered) the formula itself will not display. It does however display when the others are present.

Can anyone see a bug in this code??? Its killing me

Thanks for the help.

Look forward to hearing from you guys!

解决方案

Create a formula field for each database field. For example:

// {@CITY}
If Isnull({BILL_TO.CITY}) Then
  ""
Else 
  Trim({BILL_TO.CITY})

// {@STATE}
If Isnull({BILL_TO.STATE}) Then
  Space(2)
Else
  Trim({BILL_TO.STATE})

// {@ZIP}
If Isnull({BILL_TO.ZIP}) Then
  Space(5)  //adjust to meet your needs
Else
  Trim({BILL_TO.ZIP})

Embed each formula field in a text object.

Format text object and its fields to meet your need.

** edit **

I you have data-quality issues, address them in the STATE and ZIP formulas (because they will be a constant length). I would add the commas and spacing the text object.

这篇关于当某些字段为空时,公式将不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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