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

How to handle null values in formula 1

Status
Not open for further replies.

makk07

Programmer
Aug 22, 2007
24
US
Hi Everyone,

1.
I have a formula @LM Reasons in my report, its code is as follows:

if {@LM Bonus Reason}<>'' or
{@LM PP Reasons}<>'' or
{@LM PTO Reason}<>'' then
{@LM Bonus Reason} & ', '& {@LM PTO Reason}& ', '& {@LM PP Reasons}
else ''

i).code for @LM Bonus Reason:

if {#LMBonus} > 0
then "Last Month includes Bonuses"
else ""

II). code for @LM PTO Reason:

if {#LM PTO CashOut2} > 0
then "Last Month Includes PTO Cashout"
else ""

III). code for @LM PP Reasons:

if {#PayPeriods} > 2
then "Last Month includes 3 Paychecks due to bi-weekly cycle"
else ""


In the report for some records the formula @LM Reasons is displaying the value as follows:
Last Month includes bonuses, ,(I mean its displaying blank after both commas)

but for the above case I want to display it as follows:

Last Month includes bonuses

Any help is greatly appreciated!!. I am new to crystal reports and I am using crystal XI, please help me out.

Thanks in advance!!!!
 
Change @ML Reason

stringvar reason := '';

if {@LM Bonus Reason}<>'' then
reason := {@LM Bonus Reason};
if {@LM PP Reasons}<>'' then
reason := reason & ', ' & {@LM PP Reasons};
if {@LM PTO Reason}<>'' then
reason := reason & ', '& {@LM PTO Reason};
reason;
 
The simplest fix might be to go to file->report options->convert nulls to default values.

Otherwise, you need to figure out where the null is occurring. If the running totals can be null, then change your formulas like this, checking for the null before anything else:

if isnull({#PayPeriods}) or
{#PayPeriods} <= 2 then
"" else
"Last Month includes 3 Paychecks due to bi-weekly cycle"

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top