Home End User
New Blog Posts: Merging Reports - Part 1 and Part 2

Problem with changing totals (long)

edited March 2004 in End User
Hi All,

I have a commission report where I am adding up a total per salesperson. I
am using a variable because the commission structure is different for each
item.

When running forward through the report, the variable totals are correct,
but when running backwards through the report, the variable totals are
incorrect. This only happens on salespeople with more than one page.

IE. Janel has 40 transactions for commission. On the first page, it adds up
to $60 on the second page, $40. When going forward, the total on the second
page is $100, but when going backwards, the total is only $40...picking up
and adding only the transactions on that page.

How do I stop the values from changing once the report has calculated it the
first time through?

Here is my 'OnDetailBandPrint' code :

IsEFT : Boolean;
IsNPT, IsRPT : Boolean;
IsCorp : Boolean;
IsShortTerm : Boolean;
CurCommission : Double;

begin
{if glFirstPass then begin}
IsEFT := Pos('EFT', Transactions['Membership Type']) > 0;
IsCorp := Trim(Transactions['Membership Type']) = 'Corp';
IsShortTerm := Trim(Transactions['Membership Type']) = 'Short Term';

if IsEFT then begin
if Transactions['Description'] = 'Initial Payment' then begin
varPercentage.Value := 15;
varCommission.Value := Transactions['Extend'] * 0.15;
CurCommission := Transactions['Extend'] * 0.15;
end;
end
else if IsCorp then begin
if Transactions['Description'] = 'Initial Payment' then begin
varPercentage.Value := 10;
varCommission.Value := Transactions['Extend'] * 0.10;
CurCommission := Transactions['Extend'] * 0.10;
end;
end
else if IsShortTerm then begin
if Transactions['Description'] = 'Initial Payment' then begin
varPercentage.Value := 5;
varCommission.Value := Transactions['Extend'] * 0.5;
CurCommission := Transactions['Extend'] * 0.5;
end;
end
else if Transactions['Description'] = 'Initial Payment' then
if Transactions['Extend'] <= 349.00 then begin
varPercentage.Value := 5;
varCommission.Value := Transactions['Extend'] * 0.05;
CurCommission := Transactions['Extend'] * 0.05;
end
else begin
varPercentage.Value := 10;
varCommission.Value := Transactions['Extend'] * 0.10;
CurCommission := Transactions['Extend'] * 0.10;
end;

if Transactions['Description'] = 'PIF Renewal' then
if Transactions['Extend'] <= 349.00 then begin
varPercentage.Value := 5;
varCommission.Value := Transactions['Extend'] * 0.05;
CurCommission := Transactions['Extend'] * 0.05;
end
else begin
varPercentage.Value := 10;
varCommission.Value := Transactions['Extend'] * 0.10;
CurCommission := Transactions['Extend'] * 0.10;
end;

if Transactions['Description'] = 'EFT Renewal' then begin
varPercentage.Value := 15;
varCommission.Value := Transactions['Extend'] * 0.15;
CurCommission := Transactions['Extend'] * 0.15;
end;

if Transactions['Description'] = 'Balance Due Payment' then begin
varPercentage.Value := 5;
varCommission.Value := Transactions['Extend'] * 0.05;
CurCommission := Transactions['Extend'] * 0.05;
end;

IsNPT := Pos('NPT', Transactions['Description']) > 0;
IsRPT := Pos('RPT', Transactions['Description']) > 0;

if IsNPT then begin
varPercentage.Value := 5;
varCommission.Value := Transactions['Extend'] * 0.05;
CurCommission := Transactions['Extend'] * 0.05;
end
else if IsRPT then begin
varPercentage.Value := 3;
varCommission.Value := Transactions['Extend'] * 0.03;
CurCommission := Transactions['Extend'] * 0.03;
end;

glTotalCommission := glTotalCommission + CurCommission;
glGrandTotalCommission := glGrandTotalCommission + CurCommission;
{ end;}
end;

OnGroupFooterBandAfterGenerate I have :

varTotalCommission.Value := glTotalCommission;
varGrandTotalCommission.Value := glGrandTotalCommission;

And, I reset the glTotalCommission variable (which is just a global var) in

GroupHeaderBandBeforeGenerate :

CommLength : Integer;
CommStr : string;

begin
if Transactions['Operator Info'] <> glCurrentSalesperson then begin
glTotalCommission := 0;

CommStr := Transactions['Operator Info'];
if CommStr <> '' then
Delete(CommStr, 1, 17)
else
CommStr := 'Unknown';
{ShowMessage('Changing Operator from '+ glCurrentSalesperson + ' to '
+CommStr);}

glCurrentSalesperson := Transactions['Operator Info'];

varSalesperson.AsString := CommStr;
end;


Any suggestions as to what I am doing wrong, and how to stop it from
'recalculating' when going backwards through the report????

Thanks In Advance.

--

Regards,
Stacey R. Brodsky
ClubRunner, Inc.
(561) 746-3392

www.clubrunner.net

Comments

  • edited March 2004
    Hi Stacey,

    Try settng the Report.CachePages property to True. This will cache the page
    information in memory so there will be no descrepancy when you navigate back
    through your report.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.