Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

isnull

Status
Not open for further replies.

grierfield

Technical User
Dec 18, 2002
55
US
if isnull({profile.surgeon}) or
{profile.surgeon} = "" or
{profile.surgeon} = " " then
"F" else "T"


Question - why does this program work? how does ISNULL work?

cant find anything in Crystal user guide.
 
Fron Crystal's online help:
-------------------------------------------
IsNull (fld)
Basic and Crystal syntax.

Arguments
fld is any valid database, memo, or BLOB field.

Returns
Boolean Value

Action
Evaluates the field specified in the current record and returns TRUE if the field contains a null value.

Typical uses
You can use this function in a record selection formula to limit the report to records that have something other than a null value in the field specified. You can also use it to have the program take some action whenever it encounters a null value.
-------------------------------------------
Cheers,
- Ido


CUT, Visual CUT, and DataLink Viewer:
view, e-mail, export, burst, distribute, and schedule Crystal Reports.
 
Consider the name "IsNull" to be interchangeable with "ThereIsNoDataIn".

So, essentially, what your formula is saying is:

If ThereIsNoDataIn({profile.surgeon}) or
{profile.surgeon} = ""
Then TakeThisAction

You might wonder why, if you already have secured null value checks in the first line, why you have to also check for '= ""'. Null values and empty strings are not the same thing. IsNull will find null values, but "" is what you use to focus on empty strings.

The third line isn't necessary, if you use Trim in your second line. A refinement to your existing formula would make it look like this:

If IsNull({profile.surgeon}) or
Trim({profile.surgeon}) = ""
Then "F"
Else "T";

If you require any information on functions like IsNull or Trim, press F1 when you're in Crystal Reports. You'll find an exhaustive helpfile listing on all Crystal's functions.

Naith
 
Having come to Crystal from mainframe languages, I got a 'cultural shock' when encountering null. As Naith says, it means 'no data'. Mainframe languages mostly treat this as the same as zero.

It is actually a finer shade of meaning, the difference between 'Yes, we have no bananas' and 'I don't know how many bananas we have, it could be zero'. In Crystal, than is 0 or null and can be tested for.

Note that Cyrstal assumes that anything with a null means that the field should not display. Always do an if isnull test before anything else.

Madawc Williams
East Anglia, Great Britain
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top