Print Page | Close Window

Testing for NULL

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2022
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=440
Printed Date: 04 May 2025 at 12:09am


Topic: Testing for NULL
Posted By: TokyoAnt
Subject: Testing for NULL
Date Posted: 29 Mar 2007 at 11:30pm
Hi,
 
I have a variable that may be NULL. How can I test this?
 
I tried ISNULL(myVariable)
 
but it said it was expecting a field. (A field is required here). What's the story with that!?Confused
 
Thanks for any help in advance
 
Ant



Replies:
Posted By: wrightr
Date Posted: 31 Mar 2007 at 7:49pm
I'm a newbie, but I believe that the ISNULL() function is only for checking if a field contains a null.  

-------------
New user - Crystal Reports 9


Posted By: TokyoAnt
Date Posted: 31 Mar 2007 at 11:25pm
Thanks, I think you're correct which is why I'm asking the question.
 
Can you test for a null  valued variable in Crystal?
 
Many thanks for any answers on this
 
Ant


Posted By: TokyoAnt
Date Posted: 31 Mar 2007 at 11:40pm

In fact, there is a way to do this but it's really ugly.

When passing the value to the variable, check for null there, as this is a field from which the value is being pulled. Then if isnull(fieldValue) variable:= '1/1/1800' else variable := fieldValue.

Then it's a matter of checking the variable for this dummy date. If date is 1/1/1800, then it's actually null.  !Ugly neh!

Is there a 'correct' more elegant way this can be done in Crystal? Surely you can test a variable for null! Can't you? no?

Thanks for any help on this.

Ant

 




Print Page | Close Window