Counting in Detail Band
Hi again
Puzzled over counting in the Detail band events. Keeping it simple
with OnePass report and putting counts in the Summary band.
If I do a simple count of DBCalcVariable, the count is correct. BUT
if, for example, I declare a global variable in Calc tab, and set it to
0 in ReportBeforeStartFirstPass, I have tried counting by adding one in:
DetailBeforePrint (counts one extra)
DetailAfterGenerate (counts one too few)
DetailBeforeGenerate (counts one too few)
The obvious solution would be to use the correct value in the
DBCalcVariable, BUT in the Detail event, I am also calculating some
subtotals dependent on the data in the detail and reported to the
Summary. Hard to have confidence in that process or know how to approach
it, if I can't even count one for each record??
Scott
Puzzled over counting in the Detail band events. Keeping it simple
with OnePass report and putting counts in the Summary band.
If I do a simple count of DBCalcVariable, the count is correct. BUT
if, for example, I declare a global variable in Calc tab, and set it to
0 in ReportBeforeStartFirstPass, I have tried counting by adding one in:
DetailBeforePrint (counts one extra)
DetailAfterGenerate (counts one too few)
DetailBeforeGenerate (counts one too few)
The obvious solution would be to use the correct value in the
DBCalcVariable, BUT in the Detail event, I am also calculating some
subtotals dependent on the data in the detail and reported to the
Summary. Hard to have confidence in that process or know how to approach
it, if I can't even count one for each record??
Scott
This discussion has been closed.
Comments
As a rule of thumb, calculations should only be performed in the
TppVariable.OnCalc event. This is the only event that will fire once
per detail.
Events such as the DetailBeforePrint will fire multiple times on page
breaks etc.
See the following article on making calculations inside reports.
http://www.digital-metaphors.com/rbWiki/Delphi_Code/Calculations/Overview
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Thanks for quick reply! Yes, a lesson learned a few years back, but was
rusty on RB. Doing a lot of reports right now. Thanks.
Scott