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

Problem w/string variables

edited August 2004 in General
Hi,

I am using RB 7.04.
I have a report with one group and multiple (3) detail lines. Variable1 is
in the detail section and Variable2 is in the group header section.
Variable1 is simply calculating something based on the details and it is
invisible. Then I want to set Variable2 to the value of Variable1 so it
will display in the group header section. Right now, Variable2 comes out
blank, but according to my code for Variabe1, it is supposed to show
something.

Any suggestions?

Thanks,
Yelena

Comments

  • edited August 2004
    Hi Yelena,

    Be sure you have the correct datatype selected for Variable2. The event
    code in the OnCalc event of Variable1 should look something like the
    following (in RAP).

    procedure Variable1OnCalc(var Value: Variant);
    begin
    Value := Value + Report.DataPipeline['AmountPaid'];
    Variable2.Value := Variable2.Value + Report.DataPipeline['AmountPaid'];

    end;

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited August 2004
    This is the code I have on the OnCalc event of the variable located in the
    detail section:

    {Referece Range header text changes according to format code.}
    if (PipeSub3['format_code'] <> 1) then
    begin
    if ((PipeSub3['format_code'] = 2) OR (PipeSub3['format_code'] = 3)) then
    begin
    if (Variable63.AsString = '') or (Variable63.AsString = 'Cutoff') then
    Variable63.AsString := 'Cutoff'
    else
    Variable63.AsString := 'Reference Range/Cutoff';
    end
    else {we know it is 0}
    begin
    if (Variable63.AsString = '') or (Variable63.AsString = 'Reference
    Range') then
    Variable63.AsString := 'Reference Range'
    else
    Variable63.AsString := 'Reference Range/Cutoff';
    end;
    end else
    Variable63.AsString := '';
    end;

    Variable63 is in my first of three groups. Both varaible datatypes are
    string. The report is a 2-pass report and the format_code.value = 0. The
    text on the group is always blank. Variable63 is visible. Also, I did not
    change the timing on the variable in the detail section.

    Thanks,
    Yelena


  • edited August 2004
    Hi Yelena,

    I would suggest placing ShowMessage() calls in each of these cases to find
    out exactly what is happening in this method. This is a quick easy way to
    debug RAP code on the fly. As far as the code goes, at first glance it
    looks ok.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited August 2004
    I already did that, and everything looks correct with the code, but nothing
    is displaying. I thought it may be because it's in a subreport, not the
    main report.

    Any other ideas?

    Thanks,
    Yelena

  • edited August 2004
    Hi Yelena,

    If the correct code you posted is being fired at the proper time, then there
    has to be some place where the variable is either being reset, or simply
    that the variable is not being set at all. If you are updating a variable
    in the main report from a subreport, check to see that the global var you
    created is infact the correct value and that it is properly linked to the
    TppVariable in your main report. Also, check the timing of the variable to
    be sure it is not reseting at the wrong time.

    --
    Best Regards,

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