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

TppVariable set to dtTime always show current time

edited June 2005 in General
Hi,

I have a report with TppVariable that are dtTime.

Here is my structure :

====================================================

GroupHeader: ROUTE

Detail
ppTimeVariable -- dtTIME

GroupFooter: ROUTE
ppTimeGroupFooterVariable -- dtTIME CalcType = Detail; ResetType =
GroupBeforeFooter:ROUTE

====================================================

I first initialize the ppTimeGroupFooterVariable in the OnBeforePrint event:

procedure ppReportBeforePrint;
begin
ppTimeGroupFooterVariable.Value := EncodeTime(23,59,59,999);
end;

in the OnCalc event, I test the value of the ppTimeVariable :

procedure ppTimeGroupFooterVariableCalc(var Value: Variant);
begin
if (DayOfWeek(Report.DataPipeLine['INVOHEAD.DATE_CREAT']) = 1) then
begin
if ppTimeVariable.Value < Value then
begin
Value := ppTimeVariable.Value;
end;
end;
end;

procedure ppTimeGroupFooterVariableReset(var Value: Variant);
begin
ppTimeGroupFooterVariable.Value := EncodeTime(23,59,59,999);
end;

THE PROBLEM IS :

When the conditions are not met in the OnCalc event, I should have
"23:59:59" displayed on the report, but it always displays the current time.
If the conditions are met, it seems to work fine. I tried the following test
:

- Dropped a TppVariable on a report, set it to dtTime.
- Don't set any OnCalc or OnReset event.
- When I preview the report, the current time is displayed.

Thanks in advance,

David Caouette

Comments

  • edited June 2005
    Hi David,

    By default, when a dtTime field is reset, it will automatically be set to
    the current time. When are you resetting this variable? Why not just add
    an "else" statement below your if condition in the OnCalc setting the time
    to 23:59:59?

    --
    Regards,

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

    Best Regards,

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

    I reset it on GroupEnd. I made a mistake in my message, it was not on
    GroupBeforeFooter.

    The reason why I can't put an ELSE statement is that This variable must hold
    the minimal time value. It is calculated on DataTraversal and is based upon
    ppTimeVariable.

    procedure ppTimeGroupFooterVariableCalc(var Value: Variant);
    begin
    if (ppTimeVariable.Value < Value) then
    begin
    Value := ppTimeVariable.Value;
    end;
    end;

    If I put an ELSE statement to set the value to EncodeTime(23,59,59,999)
    after the end, there are a lot of chances that I get the wrong value.
    Anyway, thanks for the precision about dtTime variables. At my own advice,
    they should be reset to zero, instead of current time. When I want to get
    the current time, I use the TppSystemVariable...

    David


  • edited June 2005
    Hi David,

    I apologise, this is just the way ReportBuilder was designed to work. When
    a TppVariable is reset, the Clear routine is called setting the DateTime
    value to Now(). This is located in the ppVar.pas file if you would like to
    see/change this behavior.

    --
    Regards,

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

    Best Regards,

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

    David

This discussion has been closed.