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

Exceptions in Subreport----HELP!!!!!!!!!!!

Status
Not open for further replies.

michbell

Technical User
Aug 12, 2004
25
US
Before I forget, I’m using CR 9 and pulling info from an Informix Online Server(UNIX). Okay, I’m going to try to simplify this as much as possible, as this report is pretty complicated and a lot of the info is unneeded for this problem. Here’s the necessary info for my question:

SUBREPORT includes tables: part and partcost
part.nbr partcost.proc {subcost} (calculated from some fields in partcost table)
1) 2119a $2.14
2) 2119a 1 $0.75
3) 2119a 14 $0.95
4) 2119a 15 $1.50
5) 5555a $1.15
6) 5555a 2 $0.68
6) 5555a 14 $0.93 ...and so on

Different part.nbr’s sometimes have different partcost.proc’s, but they all have a partcost.proc that is null (as in #1 and #5).

This subreport is linked to the main report by: part.nbr to part.nbr and partcost.proc to prod.proc

I pass {subcost} to the main report with the following formula (named unitcost in main report):
whileprintingrecords;
shared currencyvar cost := {subcost}

MAIN REPORT includes the tables: part and prod
part.nbr part.proc prod.lbs {unitcost} {totalcost} which is calculated from -- (prod.lbs x {unitcost})
2119a 15 1,600 $1.50 $2,400
5555a 2 2,000 $0.68 $1,360
...and so on

HOWEVER, for reasons beyond my control, sometimes the prod.proc listed does not appear in the partcost table for that particular part.nbr, and when this happens the {unitcost} field returns $0:
part.nbr part.proc prod.lbs {unitcost} {totalcost}
2119a 3 1,000 $0.00 $0.00

SOOO... what I need to it to do in this last case is for it to pull the {unitcost} for the null partcost.nbr so that it looks like this:
part.nbr part.proc prod.lbs {unitcost} {totalcost}
2119a 3 1,000 $2.14 $2,140


Does anyone have any suggestions? I tried writing a formula that would show the part.proc when it equals the prod.proc but return a null field when they don’t equal each other and then link that formula to part.proc instead of linking prod.proc to part.proc, but it’s not working. If anyone has any ideas, I’d greatly appreciate them. Sorry this is so complicated – I hope I didn’t leave anything essential out. Thanks in advance!!!!
 
Try creating a default {subcost} shared variable to be used by the main report when the prod.proc listed does not appear in the partcost table for that particular part.nbr

\\Place in subreport to hold default cost value
whileprintingrecords;
If isnull({partcost.proc}) then
shared currencyvar defaultcost:= {subcost}

\\Modify Main report @totalcost calc to use default cost \\value if nessesary
If {unitcost} <> 0 then
(prod.lbs x {unitcost})
else
(prod.lbs x {defaultunitcost})

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top