string Crystal Reports合并字符串公式中的字段,一个字段没有数据
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23962342/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Crystal Reports combine fields in string formula, one field no data
提问by user3520898
I was given a formula:
我得到了一个公式:
if not (isnull({PERSON.LAST_NAME})) then
{PERSON.LAST_NAME}+","+" "+{PERSON.FIRST_NAME}
else
"No Name"
This formula seems to work fine but I need to add the field {PERSON.MIDDLE_NAME} however when I write the formula
这个公式似乎工作正常,但我需要添加字段 {PERSON.MIDDLE_NAME} 但是当我编写公式时
if not (isnull({PERSON.LAST_NAME})) then
{PERSON.LAST_NAME}+","+" "+{PERSON.FIRST_NAME}+","+" "+{PERSON.MIDDLE_NAME}
else
"No Name"
if the person has a middle name, it looks fine. If the person does not have a middle name and there is no data in the field, then the report shows no information at all.
如果这个人有一个中间名,它看起来很好。如果此人没有中间名且字段中没有数据,则报告根本不会显示任何信息。
Apologies for what is likely a very beginner question, and thank you in advance.
对于可能是非常初学者的问题表示歉意,并在此先感谢您。
回答by ryan
You can nest an additional if statement to evaluate the middle name. Sometimes I like to break criteria like this into multiple formulas. You could create a separate formula for fname, lname, mname. Each would have an if statement similar to above (if isnull({mname} then "" else {mname}).
您可以嵌套一个额外的 if 语句来评估中间名。有时我喜欢将这样的标准分解为多个公式。您可以为 fname、lname、mname 创建单独的公式。每个都有一个类似于上面的 if 语句(if isnull({mname} then "" else {mname})。
Then you can create an additional formula to concatenate them all together {lastname} + {firstname} + {middlename}
然后你可以创建一个额外的公式来将它们连接在一起 {lastname} + {firstname} + {middlename}