neronikita
Technical User
I am baffled. I have a report (work completed) with two subreports (parts and hours). Using variables, I created several formulas to pull totals from each subreport and add them up in the main report. It works... with a little flaw. If there are not any parts and/or hours for the current job, it pulls the info from the previous job in (so it will never show 0, even if it should). This throws off my totals.
The parts report is using the following formulas:
@totalpartscost:
{PartsUsed.numpartsused}*{partslist.cost}
@totalpartsshared:
Shared currencyvar TotalPartsShared;
TotalPartsShared := if ({@TotalPartsCost}) > 0 then (Sum ({@TotalPartsCost}, {DailyVehicleTracking.DailyVehicleTrackingID})) else 0
NOTE: I also tried this without the if/else parts and they work the same
The hours report uses the following formulas:
@overheadcost:
shared currencyvar overheadcost;
overheadcost := Sum ({@calcmechcost})
@alcmechcost:
{@calctime} * {@MechTime}
@calctime:
datediff("s",datetime(currentdate,{@TimeStart}), datetime(currentdate,{@timestop}))
The main report uses:
@totalpartssharedmain:
whileprintingrecords;
shared currencyvar totalpartsshared;
totalpartsshared
@overheadcostmain:
whileprintingrecords;
shared currencyvar overheadcost;
overheadcost
@totalcostfromvar:
whileprintingrecords;
{@overheadcost main} + {@totalpartssharedmain}
So the main totals will work if there are both parts AND hours are in for the given job number. If either are missing, it pulls the number from the previous job number and inserts it, giving an incorrect total. I'm not sure how to make it pull just that job number or use a zero if nothing is found, since I am already telling it to do that (or so I thought).
Please let me know if I need to give more information or explain anything further. I am using Crystal Reports 2008 and SQL Server 2008.
Thanks!
Di
The parts report is using the following formulas:
@totalpartscost:
{PartsUsed.numpartsused}*{partslist.cost}
@totalpartsshared:
Shared currencyvar TotalPartsShared;
TotalPartsShared := if ({@TotalPartsCost}) > 0 then (Sum ({@TotalPartsCost}, {DailyVehicleTracking.DailyVehicleTrackingID})) else 0
NOTE: I also tried this without the if/else parts and they work the same
The hours report uses the following formulas:
@overheadcost:
shared currencyvar overheadcost;
overheadcost := Sum ({@calcmechcost})
@alcmechcost:
{@calctime} * {@MechTime}
@calctime:
datediff("s",datetime(currentdate,{@TimeStart}), datetime(currentdate,{@timestop}))
The main report uses:
@totalpartssharedmain:
whileprintingrecords;
shared currencyvar totalpartsshared;
totalpartsshared
@overheadcostmain:
whileprintingrecords;
shared currencyvar overheadcost;
overheadcost
@totalcostfromvar:
whileprintingrecords;
{@overheadcost main} + {@totalpartssharedmain}
So the main totals will work if there are both parts AND hours are in for the given job number. If either are missing, it pulls the number from the previous job number and inserts it, giving an incorrect total. I'm not sure how to make it pull just that job number or use a zero if nothing is found, since I am already telling it to do that (or so I thought).
Please let me know if I need to give more information or explain anything further. I am using Crystal Reports 2008 and SQL Server 2008.
Thanks!
Di