Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CR 8.5 Concatenation Issue

Status
Not open for further replies.

TEM3

Technical User
Dec 6, 2004
324
US
I don't know if this is a "feature", a glitch or a default that can be changed.....

In Crystal Reports 8.5: When you concatenate two or more text fields in a formula, such as -

//@subtitle
{textfield1} & " - " & {textfield2}

and one of the fields are empty (null) and you go to print the formula, you get nothing.

I guess I can test for NULL fields and change the content of the formula, but it would be nice if it would just print the part that was populated (along with any other added text).

Any other work-arounds?
 
Yeah, you have to test for nulls, or select the Report->Options->Convert null fields to default value.

Another option woul be to let the database do the work using a SQL Expression, such as:

table.field1 & ' - ' & table.field2

You didn't bother to post your database or I might have been more accurate.

Null checks need to be the first part of a formula, so it would be:

Whileprintingrecords;
MyText1:="";
MyText2:="";
if isnull({table.text1}) then
MyText1:= "" else
MyText1:= {table.text1};
if isnull({table.text2}) then
MyText2:= "" else
MyText2:= {table.text2};
MyText1 & " - " & MyText2

-k
 
Oracle 9i. Doing the Report Option Convert to null thing sometimes causes other stange things to happen, so I usually avoid it.

You solution seems elequent enough to adopt. Thanks.....
 
It won't cause strange things to happen, it just disallows null checking. If you have a concern when using it, state particulars, strange things usually means users misunderstanding something.

Again, go with the SQL Expression, it's faster and easier:

something like:

decode(table.field1,null,'',table.field1) || ' - ' || decode(table.field2,null,'',table.field2)

Now the database does all of the work, as it should always be.

If you post technical information the first time you'll probably get it right the first time, being succinct is good, but please flesh out your environment.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top