LarryDeLaruelle
Technical User
I wrote a function to group similar Diagnoses under common headings using a Select Case statement. The Function is called from a Query and if the value I pass is null the resulting query display shows the #ERROR. Any other value passed to the Function produces the expected result.<br><br>The field I am using is Data Type Text and I am passing the value as a String. I tested to make sure that the field contained nulls by using the "Is Null" criteria in a Query.<br><br>A portion of my code:<br><br>Public Function Diagnosis(DiagnosisNum as String) As String<br> Select Case DiagnosisNum<br> Case "315.00", etc<br> Diagnosis = "Learning Disorders"<br> . . . <br> Case Else<br> Diagnosis = "Blank or Miscoded"<br> End Select<br><br>I assumed (big mistake) that any value not specified in the Case statements, including Nulls and empty strings would return the Case Else value.<br><br>I tried trapping for Nulls at the begining of the Function with:<br> If DiagnosisNum Is Null Then<br>and received a Type Mismatch error when I run the query.<br><br>I also tried:<br> If Nz[DiagnosisNum]<br>and<br> If Is Null DiagnosisNum<br>and received a compile error on each.<br><br>And I tried:<br> If DiagnosisNum = "" or DiagnosisNum = " " Then<br>which had no effect; still returned #ERROR on Null values.<br><br>This is driving me nuts!! Any suggestions will be gratefully received. Thanks.<br><br> <p>Larry De Laruelle<br><a href=mailto:larry1de@yahoo.com>larry1de@yahoo.com</a><br><a href= > </a><br>