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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crystal Reports Formula

Status
Not open for further replies.

chrissypchy

Programmer
Jun 23, 2003
40
US
Hi,
I'm using Crystal Reports 8 and I just want the string "N/A"
to appear where there are null values. I cant seem to do it. Is there a formula that can do this? I tried so many formulas and keep getting errors. Any help would be greatly appreciated. Thanks
-Chrissy
 
If Isnull({field1}) then "N/A" else {field1}

replace the {field1}'s with your database field.

Let me know how you get on......

Reebo
Scotland (Sunny with a Smile)
 
Thanks Reebo. I tried this and I get an error that says "The result of a selection formula must be a boolean".
Do you know what this means?
-Chrissy
 
this means you are most likly entering a record or group selection formula rather than creating a new formula field.

Make sure you create this formula by clicking on insert, field object, formula field.

Software Sales, Training, Implementation and Support for Exact Macola, eSynergy, and Crystal Reports
 
You are right dgillz!! I was entering a group selection. When I did the formula in the Insert Field Object area I did not get any errors and it ran. However, even when the string was not null, it still printed "N/A". I hate to be a pain but would anyone know the reason for this?
-Chrissy
 
If you put in the correct formula that should not happen:

if isnull({table.field}) then
"N/A"

else {table.field}


If the field is a number type field then you will have to convert it to text.

A check I like to do, is put the formula in the detail section and also put the database field right next to the formula and where there are blanks in the field I should see a N/A right next to it, and where there is a value in the field, that same value should show right next to it.

Like I said, I have never encountered a problem where Values were turning up as N/A when only NULL values were supposed to do that.
 
Are you sure the field is truly NULL?

You could try:

If IsNull({field}) or {field} = ""
then "N/A"
else {field}

Of course, that doesn't help if the field holds spaces.

Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Expert's Guide to Formulas / Guide to Crystal in VB
- tek@kenhamady.com
 
If the field holds spaces it's: If IsNull({field}) or Trim({field}) = ""...
 
Thanks so much to everyone for helping me. I guess the fields probably werent null after all. I was just saved a lot of time and aggrevation. Thanks again.
 
Under file, report options, there is a "convert null field values to default" checkbox. If this is activated, then null checking may not apply as described above. Try running the report with this box checked and with it unchecked and see how your results change.

Software Sales, Training, Implementation and Support for Exact Macola, eSynergy, and Crystal Reports
 
I tried that and you are right. Thanks for showing that to me!!
-Chrissy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top