IsNull Crystal Reports Custom Function

I am trying to create a custom IsNull function in Crystal Reports; the function should act in the same way as the IsNull function in MS SQL Server. I want to specify a field, and if the field is null, then it should be returned with the value I specified.

IsNull({myField},0) or IsNull({myField},'Hello World') 

I came across the fact that I need to create a separate function for numeric fields and a separate function for text fields. I also found that Crystal does not allow the use of standard functions inside a custom function, for example, ISNULL Function:

 Function(NumberVar param, Numbervar setter) IF ISNULL(param) THEN setter ELSE param 

and

 Function(StringVar param, StringVar setter) IF param = NULL THEN setter ELSE param 

Does anyone know how I can create such a function in Crystal and work around ISNULL inside a user-defined function?

+4
source share
4 answers

You cannot pass null to a user-defined function, so it makes no sense to use the crystal isnull function inside one. The only option is to write it down as ...

 if isnull({myField}) then 0 else {myField} 
+10
source

I found this problem, in the formula editor there is a dropdown in the header that indicates:

  • Exception for zeros
  • Default values ​​for zeros

Choose the second (default values ​​for zeros)

+7
source

I encountered the same behavior, but I have yet to see a documented reason for this.

I would suggest that you use an SQL statement:

 //{%myField} ( ISNULL({myField},'Hello World') ) 
+2
source

This worked for me:

 if (isnull({dbvalue}) or ({dbvalue} ='')) then "Display the required text" else {dbvalue} 
+1
source

All Articles