Look ahead problem
Hello
I'm attempting to show job percentages by department, dividing each
department total by the job total at the department group end. If the
calculated field is lookahead the job total is correct but the department
value is always from the last department, if not then the job total is
wrong.
Using D7 and Report Builder 7.03
I'm attempting to show job percentages by department, dividing each
department total by the job total at the department group end. If the
calculated field is lookahead the job total is correct but the department
value is always from the last department, if not then the job total is
wrong.
Using D7 and Report Builder 7.03
This discussion has been closed.
Comments
Where are you placing these calculated fields? Are you resetting certain
DBCalcs based on some groups? Are you using any TppVariables? I will need
a little more information about how your report is designed to help you with
this one.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
The report has 2 groups. Group 1 is on labor codes, group 0 is on
departments. Time totals from the detail lines are multiplied by the hourly
rate for that code on footer 1 in a tppvariable. This is then totaled for
the department in anther tppvariable on the department footer. The grand
total for the job is on the report title. All of that works. Trying to
divide the department total by the job grand total on the department footer
is the problem. The department total is calculated on the code group end and
reset on department group end. The grand total is calculated on the dept
group end and reset at report end.
procedure TfrmJobCost2.vPhaseChargeCalc(Sender: TObject;
var Value: Variant);
begin
Value := dbcPhaseTimeTotal.Value * dbtPhaseRate.FieldValue;
end;
procedure TfrmJobCost2.vDeptChargeCalc(Sender: TObject;
var Value: Variant);
begin
Value := Value + vPhaseCharge.AsCurrency;
end;
procedure TfrmJobCost2.vJobLaborTotalCalc(Sender: TObject;
var Value: Variant);
begin
Value := Value + vDeptCharge.AsCurrency;
end;
procedure TfrmJobCost2.vDeptPctCalc(Sender: TObject; var Value: Variant);
begin
Value := vDeptCharge.AsCurrency /vJobLaborTotal.AsCurrency;
end;
Regards,
Rob
When you set a LookAhead variable, it will not actually be available for
calculations until the report has completely finished it's first pass. At
the time you are accessing it's value, it is probably still calculating
internally the grand total. Try placing a check inside your vDeptPctCalc
event to be sure it only calculates on the second pass of the report. (i.e.
if (Report.SecondPass) then...).
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com