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

Running total on variable 1

Status
Not open for further replies.

BradCustom

IS-IT--Management
Oct 5, 2007
296
US
I'm using Crystal Reports 2016 and I'm having a problem with displaying the calculated running total in the report footer. As long as I don't Hide or Suppress the Detail or Group footer all of the formulas calculate correctly. If I Hide or Suppress the Detail or Group footer (which is what I want to do) the running calculation displays a value that doesn't make any sense. I'll describe the report structure and formulas as best I can below.

The main report has three tables Job, Job_Operation and Job_operation_Time
There is one Subreport which has one table Job_Operation the subreport is linked to the main report by the Job field. I'm using the Job Operations subreport to find the Max job.sequence I pass that value to the main report. The subreport is in Details B section, all the of other fields are in Details A section. The Scrap Cost Each formula is in Group 1 footer.

Group 1 = Job
Group 2 = Work Center

Below are the formulas I'm using to calculate the the scrap cost for each detail line,
Code:
 whileprintingrecords;
shared currencyvar ScrapCost :=
scrapcost + 
(if {Job_Operation.Sequence}=0
then
({@LineCostEa}*(({Job_Operation.Sequence}+1)/({@Pass_JobOpSeq}+1)))*{Job_Operation_Time.Act_Scrap_Qty}
else
if {@Pass_JobOpSeq}=0
then
({@LineCostEa}*(({Job_Operation.Sequence}+1)/({@Pass_JobOpSeq}+1)))*{Job_Operation_Time.Act_Scrap_Qty}
else
({@LineCostEa}*({Job_Operation.Sequence}/{@Pass_JobOpSeq}))*{Job_Operation_Time.Act_Scrap_Qty})

Below is the formula I using to create a running total for the scrap cost.
Code:
 whileprintingrecords;
shared currencyvar ScrapCost :=
scrapcost + 
(if {Job_Operation.Sequence}=0
then
({@LineCostEa}*(({Job_Operation.Sequence}+1)/({@Pass_JobOpSeq}+1)))*{Job_Operation_Time.Act_Scrap_Qty}
else
if {@Pass_JobOpSeq}=0
then
({@LineCostEa}*(({Job_Operation.Sequence}+1)/({@Pass_JobOpSeq}+1)))*{Job_Operation_Time.Act_Scrap_Qty}
else
({@LineCostEa}*({Job_Operation.Sequence}/{@Pass_JobOpSeq}))*{Job_Operation_Time.Act_Scrap_Qty})

Below is the formula to display the running total in the Report Footer.
Code:
 whileprintingrecords;
shared currencyvar scrapcost

Hopefully I gave enough information, if I didn't please let me know.
Thank you for your help!
 
Sorry everyone, I noticed this morning that I posted the same formula twice. The formula for the Scrap Cost for each line is wrong in the above post.

Below is the correct Scrap Cost for each detail line.
Code:
 (({Job.Est_Labor}+{Job.Act_Material}+{Job.Act_Service})/{Job.Make_Quantity})

 
It appears the problem would be resolved if you could just make the subreport disappear. You can't suppress the subreport directly or the section it is in directly, because then the shared variable won't pass, but you can do the following:

Within the subreport, suppress all sections. In the main report, check "suppress blank subreport" (format->subreport->subreport tab), remove the borders from the subreport (select the subreport->format->borders and change to "no line" for each edge), and in the section expert, format detail_b to "suppress blank section".

-LB
 
Thank you lbass, that works perfectly!

I did make one change because I want to hide the detail section. I moved the subreport to Group Footer 2.

Thank you for your help!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top