title: Crystal Reports formula: IsNull + Iif
body: <p>There are hints of the answer to this question here and there on this site, but I'm asking a slightly different question.</p>
  
  <p>Where does Crystal Reports document that this syntax does not work?</p>
  
  <pre><code>Trim({PatientProfile.First}) + " "
      + Trim(Iif(
          IsNull({PatientProfile.Middle}) 
          , Trim({PatientProfile.Middle}) + " "
          , " "
          )
      )  
  + Trim({PatientProfile.Last})
  </code></pre>
  
  <p>I know the solution is</p>
  
  <pre><code>If IsNull({PatientProfile.Middle}) Then
      Trim({PatientProfile.First})
          + " " + Trim({PatientProfile.Last})
  Else
      Trim({PatientProfile.First})
         + " " + Trim({PatientProfile.Middle})
         + " " + Trim({PatientProfile.Last})
  </code></pre>
  
  <p>but how are we supposed to figure out we can't use the first version?</p>
  
  <p>The documentation for IsNull says </p>
  
  <ul>
  <li>Evaluates the field specified in the current record and returns TRUE if the field contains a null value</li>
  </ul>
  
  <p>and Iif gives</p>
  
  <ul>
  <li>[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.</li>
  </ul>
  
  <p>I suppose if you stare at that line about "type of the return value" you can get it, but...</p>