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!

Choose field

Status
Not open for further replies.

keo216

Technical User
Nov 26, 2002
102
US
This is a pretty fundamenal question but I'm hung up.......
I am using CR 8.5

I have {Field1}, {Field2}, and {Field3}.

I want to multilpy {Field3} by either {Field1} or {Field2}.

I have to choose either {field 1} or {field 2} based on whether {field 1} is either 0 or null. If {Field1} is either null or 0 then I have to choose {Field2}. If {Field1} has a value greater than 0 then I choose {Field1}.

({Field1} or {Field2}) * {Field3}

kowen@rrwa.net
 
Code:
If isnull ({Field1}) or {Field1} = 0
then {Field2} * {Field3} 
else {Field1} * {Field3}
That's assuming {Field2} is never null - you'd get a blank field if it were.

Note that nulls must always be the first thing tested for, because a formula stops without output when a null is encountered unexpectedly.


[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
Try:

if isnull({table.field1}) or
{table.field1} = 0 then
{table.field2} * {table.field3} else
{table.field1 * {table.field3}

-LB
 
thanks, my problem was I was not testing for null FIRST.

kowen@rrwa.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top