Summary Band Calculations Issues
I need to supress the printing of data based upon certain conditions.
I need to hide the header, detail, and summary when the sum of a qty is
zero.
This qty can not be easily computed in a query, so I'm depending upon the
value in the report.
I have set up a two pass report, and I have set up a temp table
(kbbmemtable) to hold the values I want to store in the first pass, and then
during the second pass, I will hide/show based upon this value.
I have a hidden variable in the summary band with the following code:
if ppreport1.FirstPass then
begin
tblLocationItemQty.Insert;
tblLocationItemQtyLOCATION.AsString :=
qryItems.fieldbyname('LOCATION').AsString;
tblLocationItemQtyITEMNMBR.AsString :=
qryItems.fieldbyname('ITEMNMBR').AsString;
tblLocationItemQtyITEMNMBR.AsIntege r:=
qryItems.fieldbyname('QTY').AsInteger;
tblLocationItemQty.Post;
end;
For some reason, I am getting duplicates in my temp table, even though it
should be unique. It seems as if the variable calc is firing multiple
times, and I don't know why.
A couple points to ponder:
These bands are wrapped up in a subreport, where KeepTogether is set to
true, It seems that in previous posts you have indicated this may cause a
double fire, and I'm not sure why.
Calc Type I have tried is ReportEnd, and transversal..
Any ideas why this is happening?
Should I not have the variable in Summary and place it somewhere else? I
have also tried placing the code the AfterGenerate for the Summary band and
I had the same behavior.
Any examples of this?
And I swear I searched the newsgroups for the answer before asking...
Thanks,
John
I need to hide the header, detail, and summary when the sum of a qty is
zero.
This qty can not be easily computed in a query, so I'm depending upon the
value in the report.
I have set up a two pass report, and I have set up a temp table
(kbbmemtable) to hold the values I want to store in the first pass, and then
during the second pass, I will hide/show based upon this value.
I have a hidden variable in the summary band with the following code:
if ppreport1.FirstPass then
begin
tblLocationItemQty.Insert;
tblLocationItemQtyLOCATION.AsString :=
qryItems.fieldbyname('LOCATION').AsString;
tblLocationItemQtyITEMNMBR.AsString :=
qryItems.fieldbyname('ITEMNMBR').AsString;
tblLocationItemQtyITEMNMBR.AsIntege r:=
qryItems.fieldbyname('QTY').AsInteger;
tblLocationItemQty.Post;
end;
For some reason, I am getting duplicates in my temp table, even though it
should be unique. It seems as if the variable calc is firing multiple
times, and I don't know why.
A couple points to ponder:
These bands are wrapped up in a subreport, where KeepTogether is set to
true, It seems that in previous posts you have indicated this may cause a
double fire, and I'm not sure why.
Calc Type I have tried is ReportEnd, and transversal..
Any ideas why this is happening?
Should I not have the variable in Summary and place it somewhere else? I
have also tried placing the code the AfterGenerate for the Summary band and
I had the same behavior.
Any examples of this?
And I swear I searched the newsgroups for the answer before asking...
Thanks,
John
This discussion has been closed.
Comments
calculating values for a TppVariable, the value is always cached and ready
to calculate the second time as if it never calculated the first time when
it must repeat to support KeepTogether page breaks.
To workaround this, and since you have a string, and integer values, you
could uses Delphi's TStringList and set Duplicates to dupIgnore for the
strings. For the integer's, add them as TObjects in a TList, checking
List.IndexOf() = -1 to see if it should be added to the list. Then at the
end of the first pass you'll have the data in three lists, with list counts
that equal the record count of your dataset. Then you can pull this data
from the lists in the second pass in your event handlers for the report by
checking if Report.SecondPass then. You could wrap this up into a
JITPipeline. Use the JIT to pull data from either the dataset directly, or
your lists.Use this example to model the JIT to work over a TDataset
descendent and extend it to chek the field name to pull data from the
dataset or the lists as needed.
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
Pipeline to Store the values. So what I ended up doing and it may be of use
to others, was to get a a product called "Txquery" which is a cool little
Component that let's you issue sql statments and return results against any
of the the other datasets you are using (be it, SQL, dbIsam etc) So it was
just the glue I needed. I simply grouped by some key fields, and summed the
QTY (but really you could stick any logic here), linked it my real datasets,
set up a pipeline, and when in the header checked for my QTY = 0 and if so,
hid my bands. I hope this might someone else who is having problems with
trying a similar problems and having problems with calculations timing and
such.
Thanks again,
John