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

Problem getting on calc event in variables to work

edited November 2005 in General
The Problem:



I have an invoice I have created in RB Ver 9.03, it has a master detail
datasource invoice and details, the detail band is connected to the Details
datasource, and each band has 2 variables called ppVariableVAT and
ppVariableSubTotal, these are set with the following conditions

CalcComponet = ppDetailBand1

CalcType = veTraversal

Reset Type = veReportEnd

ResetComponent = {empty}



These Variables have the following on calc events:

procedure TFormRBVoucher.ppVariableSubTotalCalc(Sender: TObject;

var Value: Variant);

Var

rvat, rGross,

rSubNet :Double;

begin

rSubnet:= IBOQueryACVitm.FieldByName('zvcost').AsFloat *
IBOQueryACVitm.FieldByName('zvqty').AsFloat;

rSubNet:= StrToFloat(Format('%2.2f',[rsubnet]));

Value := StrToFloat(Format('%2.2f',[rsubnet]));

end;



procedure TFormRBVoucher.ppVariableVATCalc(Sender: TObject;

var Value: Variant);

Var

rvat, rGross,

rSubNet :Double;

begin

rSubnet:= IBOQueryACVitm.FieldByName('zvcost').AsFloat *
IBOQueryACVitm.FieldByName('zvqty').AsFloat;

rSubNet:= StrToFloat(Format('%2.2f',[rsubnet]));

rVat := IBOQueryACVITM.FieldByName('zvatamnt').AsFloat; // After sep2005

Value := rvat;

end;



THESE WORK PERFECTLY ON EVERY BAND ON EVERY PAGE !

My Problem is I want a total of the Net, VAT and Gross figures on the footer
of the last page only. My problem is that if the report is longer than 1
page it excludes the figures from totals of the first band on ANY last page
of the report, whilst printing them perfectly on the page the values are not
added to the totals at the end of the report. its like the on calc event is
not firing for the first detail band on the last page, but works for the
detail bands variables fine.



The Code for the 3 totals are :



Procedure TFormRBVoucher.ppVariable1Calc(Sender: TObject; var Value:
Variant);

begin

value := Value + ppVariableSubTotal.Value;

end;



procedure TFormRBVoucher.ppVariable2Calc(Sender: TObject; var Value:
Variant);

begin

value := Value + ppVariableVAT.Value;

end;



Procedure TFormRBVoucher.ppVariable3Calc(Sender: TObject; var Value:
Variant);

Var

rVal ,rNet, rVat :Double;

begin

rVal := ppVariable1.Value;

rNet := StrToFloat(Format('%2.2f',[ rVal ] ));

rVal := ppVariable2.Value;

rVat := StrToFloat(Format('%2.2f',[ rVal ] ));

value := rVat + rnet;

end;



The Settings for the 3 Total variables on the footer are :



CalcComponent = ppDetailBand1

CalcType = veTraversal

Reset Component = ppReport1

Reset Type = veReportStart





Don't know if this makes any difference but all the footer info is in a
region that gets switched on and off so I can show a "More follows..."
message at the previous page footers in stead of the totals, I do this by :



if ppreport1.PageNo = ppReport1.PageCount then

Begin

ppRegionContinue.Visible := False;

ppRegionTotals.Visible := True;

End

Else

Begin

ppRegionContinue.Visible := True;

ppRegionTotals.Visible := False;

End;





if anyone can help i would very much appreciate it.



Thanks



Colin coleman

Comments

  • edited November 2005
    Hi Colin,


    If you would just like the total variables on the last page, you should use
    the Summary band instead of the Footer band.

    Looking at your code, it looks like it may be a timing issue. You have all
    your variables set to calcuate on traversal but you are using the calculated
    values of some variables inside other variable's OnCalc event. Try simply
    updating the values of the variables in the footer band inside the OnCalc
    events of the variables in the detial band. For instance at the end of the
    OnCalc event for VariableSubTotal, you could say....

    ppVariable1.Value := ppVariable1.Value + Value;

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited November 2005
    Hi Nico,

    Thanks for the reply, i tried your idea, and it works,

    You say i should be using the summary instead of the footer band, I have
    spent hours in the past trying to use this but have been unable to anchor it
    to the base of the last printed page, and not to throw a empty page with
    just the summary on it. What do i need to set to use the summary band ?

    Thanks
    Colin





  • edited November 2005
    Hi Colin,

    You can set the PrintPosition of the Summary band to define its vertical
    position on a page. This property is measured in Report units. You can
    also try adjusting the BottomOffset property to hopefully prevent the
    summary band from being orphaned on the last page.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited November 2005
    Hi Nico,

    Im having the good old problem with the summary band, maybe you could shine
    some light on the problem for me, it appears that the height of the footer
    band plays a big part in positioning the summary band, regardless of wether
    it is turned off or on for the "Print on LastPage" ,so i can NEVER get the
    summary page to sit FLAT on the bottom of the last page.

    I have put my message "Continued on next page" in the Footer band , and if
    its not the last page i make the band visible in the footer before generate
    event....is this correct ? or just a rubbish way of using the band ?

    Thanks

    Colin


  • edited December 2005
    Hi Colin,

    Unfortunately ReportBuilder allocates space for the footer band regardless
    if it's visible or not. The method you are using to incorporate both the
    summary and footer band is probably how I would do it too.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

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