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!

ifthenelse evaluation problem 1

Status
Not open for further replies.

dmccallum

Programmer
Jan 5, 2001
90
US
I'm grouping on Invoice Number. Within Invoice Number there can be multiple product codes. If there is ever a product code 80 within an invoice number I want to use one formula but if there is never a product code 80 I want to use another formula. I have tried simply saying:

IF {Line_.Pr_Code} = "80"
then {@NetCostInstalled}
else {Line_.Net_Cost})

but whether I put the above formula in the header or in the details it only reads the first product code number and basis the decision upon that and 80 might be in the third product code.

I also tried:

WhileReadingRecords;

and

WhilePrintingRecords;

with no difference. I also tried placing the formula in the group footer. I also tried

Do IF {Line_.Pr_Code} = "80"
then {@NetCostInstalled}
else {Line_.Net_Cost})
While Header_.InvNum = Group Header_.InvNum

but received an error message because the above formula was needed in another formula.

Is there a way to evaluate all the product codes within a group before performing any calculations?
 
This formula needs to be in the details section and you simply summarize that formula by invoice #. Software Support for Macola, Crystal Reports and Goldmine
dgillz@juno.com
 
Like this?

IF {Line_.Pr_Code} = "80"
then SUM({@NetCostInstalled},Header_.InvNum)
else SUM({Line_.Net_Cost},Header_.InvNum)
 
That totals the {@NetCostInstalled} or the {Line_.Net_Cost} field for the Invoice Number but I need the individual field/formula for each detail line.
 
Like this:

If {Line_.Pr_Code} = "80" then {@NetCostInstalled} else {Line_.Net_Cost}

Then summarize this formula. Software Support for Macola, Crystal Reports and Goldmine
dgillz@juno.com
 
dmcallum,

Anytime you want know if a condition is met anywhere within the group you can write a formula that says:

if {field} = '80' // or any condition
then 1 else 0


Now in the footer you can say:

If Sum({formula},{group}) > 0 //ie if any 80s exist
then {@NetCostInstalled}
else {Line_.Net_Cost} Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top