Variables not Calcing
Greetings,
I have a report grouped by salesman.
I have followed the Percent of GroupTotal example to the T.
Basically it's an Accounts Receivable Aging by Salesman report and I'm
taking each of the aging values and dividing it by the total receivable for
the salesman to come up w/ a percent.
I use variables to calc the Percents.
All works perfectly EXCEPT for two salesmen that fall in the middle of the
report.
All other salesmen percents calc out perfectly except these two.
I've gone into debug and the numbers look right, just seems the VALUE
variable does not get assigned.
Any help here would be GREATLY appreciated.
Kevin Stanton
RDB Solutions
I have a report grouped by salesman.
I have followed the Percent of GroupTotal example to the T.
Basically it's an Accounts Receivable Aging by Salesman report and I'm
taking each of the aging values and dividing it by the total receivable for
the salesman to come up w/ a percent.
I use variables to calc the Percents.
All works perfectly EXCEPT for two salesmen that fall in the middle of the
report.
All other salesmen percents calc out perfectly except these two.
I've gone into debug and the numbers look right, just seems the VALUE
variable does not get assigned.
Any help here would be GREATLY appreciated.
Kevin Stanton
RDB Solutions
This discussion has been closed.
Comments
is where the problem lies. One thing to check would be the DisplayFormat of
the variable. It is possible that the percentages are coming out small
enough that they are being truncated to 0.
--
Cheers,
Alexander Kramnik
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
I checked this once, but I will reverify.
The datatype is dtDouble.
Displayformat = ##0.00 % (I even tried removing this altogether).
I have just tried using a ppLabel and it shows just fine.
Here is the code:
procedure TrbARAgingDetail.varTPct1Calc(Sender: TObject;
var Value: Variant);
var
liIndex: Integer;
FullName : String;
Tot, Amt : Integer;
Pct : Double;
begin
if (ppReport1.SecondPass) then
begin
FullName := qryOpenInvFullName.AsString; // this is just for
debugging so I could stop on the saleman's name
liIndex := grpTrader.BreakNo;
Tot := Integer(FTraderTotals0[liIndex]);
Amt := Integer(FTraderTotals1[liIndex]);
If (Integer(FTraderTotals0[liIndex]) <> 0) and
(Integer(FTraderTotals1[liIndex]) <> 0) then
begin
// Value := (Integer(FTraderTotals1[liIndex]) /
Integer(FTraderTotals0[liIndex])) * 100
Pct := (Amt / Tot) * 100;
Value := Pct;
lblPctT1.Caption := Format('%5.2f', [Pct]) + '%'; // this was
just added and the Caption shows the correct %: 16.13
end
else
Value := 0;
end // if ppReport1.SecondPass
end
Thanks for the reply!
Kevin
"Alexander Kramnik (Digital Metaphors)" wrote
Pct := (Amt / Tot) * 100;
to
Pct := (Double(Amt) /(Double( Tot)) * 100.0;
because it is probably performing integer division.
--
Cheers,
Alexander Kramnik
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com