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 ...