There are hints of the answer to this question here and there on this site, but I'm asking a slightly different answer.
Where does Crystal Reports document that this syntax does not work?
Trim({PatientProfile.First}) + " "
+ Trim(Iif(
IsNull({PatientProfile.Middle})
, Trim({PatientProfile.Middle}) + " "
, " "
)
)
+ Trim({PatientProfile.Last})
I know the solution is
If IsNull({PatientProfile.Middle}) Then
Trim({PatientProfile.First})
+ " " + Trim({PatientProfile.Last})
Else
Trim({PatientProfile.First})
+ " " + Trim({PatientProfile.Middle})
+ " " + Trim({PatientProfile.Last})
but how are we supposed to figure out we can't use the first version?
The documentation for IsNull says
- Evaluates the field specified in the current record and returns TRUE if the field contains a null value
and Iif gives
- [Returns] truePart if expression is True and falsePart if expression is False. The type of the returned value is the same as the type of truePart and falsePart.
I suppose if you stare at that line about "type of the return value" you can get it, but...