JIT Pipeline - DBCalc group sum always returns 0
Hi
I am using RB pro 6.03, with a JIT pipeline.
If I try to get the sum of a numeric field in a group footer using DBCalc, I
always get 0 value.
(In this scenario, the only calc type that returns a correct value is
"count").
Any suggestion?
Thank you very much.
Roberto
I am using RB pro 6.03, with a JIT pipeline.
If I try to get the sum of a numeric field in a group footer using DBCalc, I
always get 0 value.
(In this scenario, the only calc type that returns a correct value is
"count").
Any suggestion?
Thank you very much.
Roberto
This discussion has been closed.
Comments
support@digital-metaphors.com?
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
I made some changes to my code, and now DBCalc is returning the correct sum.
The only way I have found to make it working is to "force" the variant value
to float with StrToFloat, it the event "OnGetFieldValue". For example, in
the code that follows, the only double field that sums correct is
"MyDoubleC"
(By the way I tried to use "OnGetFieldAsDouble" as well, but it never seems
to fire in my code.)
---------------------------------
code example
---------------------------------
function TForm1.ppJITPipeline1GetDataSetName: String;
begin
Result := 'MyDataset';
end;
function TForm1.ppJITPipeline1GetFieldValue(aFieldName: String): Variant;
var
s:string;
begin
{ ListBox1 contains 4 items: '1', '2', '3', '4'
MyString is a JITPipeline field of type dtString
MyDoubleA is a JITPipeline field of type dtDouble
MyDoubleB is a JITPipeline field of type dtDouble
MyDoubleC is a JITPipeline field of type dtDouble
}
s:=ListBox1.Items.Strings[ppJITPipeline1.RecordIndex];
if aFieldName='MyString' then Result := 'String' + s
else
if aFieldName='MyDoubleA' then Result := 999 // NOT WORKING: MyDoubleA
DBCalc sum returns 0
else
if aFieldName='MyDoubleB' then Result := s // NOT WORKING: MyDoubleB
DBCalc sum returns 0
else
if aFieldName='MyDoubleC' then Result := StrToFloat(s); // THIS IS
WORKING! MyDoubleA DBCalc sum is OK (returns 10)
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
ppJITPipeline1.RecordCount := ListBox1.Count;
ppReport1.Print;
end;
---------------------------------
Best regards,
Roberto
to
controls to treat it as a double. You have to return a double if you want
the data aware control to behave correctly. You have found the two options
that work to do this.
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com