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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Null To Zero function

Status
Not open for further replies.

nickfatool

IS-IT--Management
Oct 8, 2001
30
0
0
AU
CR8.5Dev, Access97, ODBC

I'm trying to replicate VB's Nz "null to zero" function within a Crystal formula, is this the correct method?

Code:
IIF(IsNull({db.Field1}),0,{db.Field1})

Not getting the desired results:
Falsepart - formula returns field1 when it is not null - ok that's good.
Truepart - returns nothing when field1 is null, require zero.

Any clues?

Cheers,

Rob Dexter.
 
Ooops!
Field1 is numeric and NZ is a VBA function.
 
The Crystal formula syntax is:
"if IsNull({table.field}) then 0 else {table.field}"
 
is {db.Field1} a numeric field?? Crystal likes both to be the same type. If it is a string then use "0" instead of 0

you could also try the formula

@convertnulls

whilePrintingrecords;

if not isnull({db.Field1}) then
{db.Field1}
else
0; // or "0"; if {db.Field1} is a string

you could also set your options to convert a null to a default value....but I don't like doing that since it is hard on maintenance later (you forget you did that :) )

hope this helps Jim

JimBroadbent@Hotmail.com
 
You can also try this: under the file menu, select options, and select the "convert null field valaues to default" checkbox. Software Support for Macola, Crystal Reports and Goldmine
dgilsdorf@mchsi.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top