Solved

Crystal IF statement sometimes evaluates null. How is this possible?

Posted on 2014-09-24
211 Views
I have the follwoing IF statement in a formula and I was expected it to never evaluate null which is why the "none" is added at the end. I will be adding more to this formula but I want it to work thus far before I proceed.

If (Not(IsNull({ARACCOUNT.ZZACPENDINS}))) and ({ARACCOUNT.ZZACPENDINS} < 0.00) Then
"Insurance balance is negative - Notify Kathy"
Else If ({ARACCOUNT.ZZACSPORIGAMT} = 0) Or (IsNull({ARACCOUNT.ZZACSPORIGAMT})) Then
"No charges"
Else If ({ARACCOUNT.ZZACSPORIGAMT} - {ARACCOUNT.ZZACSPINSPMT} - {ARACCOUNT.ZZACSPINSADJ} - {ARACCOUNT.ZZACSPPMT} - {ARACCOUNT.ZZACSPADJ}) <> {ARACCOUNT.ARACNBTOTINI} Then
"Mathematical issue"
Else
"None"
0
Question by:altosax

LVL 100

Accepted Solution

mlmcc earned 400 total points
ID: 40342841
You need to test for NULL first.

When Crystal evaluates a formula and  it encounters a NULL in a test other than IsNull , evaluation terminates and the value returned cannot be predicted.

``````If (Not(IsNull({ARACCOUNT.ZZACPENDINS}))) and ({ARACCOUNT.ZZACPENDINS} < 0.00) Then
"Insurance balance is negative - Notify Kathy"
Else If (IsNull({ARACCOUNT.ZZACSPORIGAMT}))  OR ({ARACCOUNT.ZZACSPORIGAMT} = 0) Then
"No charges"
Else If ({ARACCOUNT.ZZACSPORIGAMT} - {ARACCOUNT.ZZACSPINSPMT} - {ARACCOUNT.ZZACSPINSADJ} - {ARACCOUNT.ZZACSPPMT} - {ARACCOUNT.ZZACSPADJ}) <> {ARACCOUNT.ARACNBTOTINI} Then
"Mathematical issue"
Else
"None"
``````
If any of the fields in the final IF can be NULL you have to handle them also.

mlmcc
0

LVL 34

Assisted Solution

James0628 earned 100 total points
ID: 40343606
If you don't specifically need to see the nulls and just need to keep them from "breaking" your formula, then another option might be to change how CR handles nulls.

More recent versions of CR have an option in the formula editor to control how CR handles nulls in a specific formula.

Or, you can go to File > "Report Options" and check the "Convert database null values to default" option, but that will affect just about every formula in the report, so if there are any other formulas where you actually need to see null values, you may not want to use that setting.

James
0

Featured Post

Suggested Solutions

countHi challenge 25 84
wordappend challenge 8 84
Crystal Reports - group header 2 28
Please explain: Aspect Oriented Programming 2 51
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …