Crystal Reports Formula: IsNull + Iif

There are hints of an answer to this question here and there on this site, but I ask a slightly different question.

Where does Crystal Reports report that this syntax is not working?

Trim({PatientProfile.First}) + " "
    + Trim(Iif(
        IsNull({PatientProfile.Middle}) 
        , Trim({PatientProfile.Middle}) + " "
        , " "
        )
    )  
+ Trim({PatientProfile.Last})

I know the solution

If IsNull({PatientProfile.Middle}) Then
    Trim({PatientProfile.First})
        + " " + Trim({PatientProfile.Last})
Else
    Trim({PatientProfile.First})
       + " " + Trim({PatientProfile.Middle})
       + " " + Trim({PatientProfile.Last})

but how should we understand that we cannot use the first version?

The documentation for IsNull says

  • Computes the field specified in the current record and returns TRUE if the field contains a null value

and iif gives

  • [Returns] truePart if the expression is True and falsePart if the expression is False. The return type is the same as truePart and falsePart.

I suppose if you look at this line about the "return type", you can get it, but ...

+5
4

, CR , IIF. "Trim ({PatientProfile.Middle)), aganst, CR, , .

+5

Crystal Reports , ?

, , , Crystal Reports...

+10

, , , . , Crystal Reports, IBM.

, Crystal Reports 8.x 10.x, ISNULL IIF . :

< >

Crystal Reports 8.x 10.x , . "IIF" "IsNull" "Not" IsNull; , IIF (Not IsNull()).

"If-Then-Else". ,

If IsNull({~CRPT_TMP0001_ttx.install_date}) Then "TBD" Else "In Progress"

, CR 8.x 10.x( ), . , , NULL.

+5

:

currencyvar tt;
currencyvar dect;
tt :={ship.comm_amount};
dect := tt - Truncate(tt);
tt := truncate(tt);
dect := dect * 100;
if dect = 0 then
UPPERCASE('$ ' + ToWords (tt,0 )) + ' ONLY'
else
UPPERCASE('$ ' + ToWords (tt,0) + ' And ' + ToWords(dect,0)) + ' ONLY ';
-3

All Articles