How to compare null value in crystal report

I'm trying to build a report using some very incomplete data provided to me. For the life of me -- I can't figure out how to format it the way I need it.

Here's what I'm trying to do:


//I'm trying to concatenate the fields to be inserted into a line on a contract form showing the "name, company, address 1, address 2, city, state zip".

//I've set up a formula field to be embedded formula in a text box which contains the agreement.

//The simple concatenation formula is: & ", " & & ", " & & ", "& & ", " & & ", " & &" " &
//It needs to provide that if the field is empty an empty string is inserted.
//Want to also eliminate the punctuation after empty fields
//The fields to be concatenated are all formatted as strings

I have tried using IsNull and also assigning emply fields as "" but can't seem to get any formulats to work. Am I missing something simple?

Edited by dfolzenlogen - 23 Feb 2008 at 5:39pm

When doing something like this, I like to use the IIF() function within my concatenation formula. The IIF() function returns one value when a condition is true and another value when false.

IIF(IsNull(), "", & ",")


THis code returns "" if it is null, otherwise it returns the field with a comma at the end. You'll need to concatenate all these together and still play with the commas a bit to get the formatting perfect, but that is the way I would approach it.

Thank you for the quick reply. Will give it a go!!

Worked like a charm!!

Glad to hear it. I have all the Crystal Reports formulas and sample code document in three chapters in my book Crystal Reports Encyclopedia.

I actually bought your book last year. Has tons of great info. I would have referred to it but a friend borrowed the book a few weeks ago and has not returned it.

I tried using this and am concatenating the fields together. It does not appear to be working. Here's what I have. Any suggestions?

IIF(IsNull(), "", & ",") &
IIF(IsNull(), "", & ",") &
IIF(IsNull(), "", & ",")

Solution for your problem: