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

Basic problems with groups and "squeezed" fields

edited October 2008 in General
?I have various reports that I am generating that I'd like to use squeezed
name and address fields for. I do a grouping and create label and memo
fields that I then generate on the fly. The issue is that when I generate
the report the same address or name value shows up in each repeated band.
I need to be able to calculate and display the values on a per-record
basis. Everything else (read: DB-linked fields) works fine.

Thoughts?

- Matt

MattC

--- posted by geoForum on http://delphi.newswhat.com

Comments

  • edited October 2008
    Hi Matt,

    How are you accessing the data to be displayed inside the label or memo? If
    your report is properly connected to a datapipeline, you should assign the
    value of the label and memo objects inside the Band.BeforePrint event is a
    similar fashion...

    Label.Caption := Report.DataPipeline['FirstName'] + ' ' +
    Report.DataPipeline['LastName'];

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited October 2008
    Yes, I am using a data pipeline and I am accessing it as such:

    { Create the "Primary Name" }
    stPrimaryName := ppMasterPipeline['FIRST_NAME'];
    stLine := ppMasterPipeline['MIDDLE_NAME'];

    if (Length(stLine) > 0) then begin
    stPrimaryName := stPrimaryName + ' ' + stLine;
    end;

    stLine := ppMasterPipeline['LAST_NAME'];

    if (Length(stLine) > 0) then begin
    stPrimaryName := stPrimaryName + ' ' + stLine;
    end;

    laPrimaryName.Caption := stPrimaryName;

    This results in the same name appearing over and over in the repeated group.


    MattC

    --- posted by geoForum on http://delphi.newswhat.com
  • edited October 2008
    Let me give a specific example. I have a report called "Brokerage Account
    Report". It's correctly connected to a pipeline called ppBrokeragePipeline
    and it is grouped on a field called "BROKERAGE_ACCOUNT_SEQNO". There is a
    label called "laBrokerageAdvisor" that is supposed to be a concatenation
    of two fields in the query hooked up to the pipeline called
    "ADVISOR_FIRST_NAME" and "ADVISOR_LAST_NAME". There is also a memo field
    called mBrokerageAdvisorAddress that is a squeezed address of various
    ADVISOR_* fields. Here is the code:

    procedure TdmReports.ppBrokerageAccountsBeforePrint(Sender: TObject);
    var
    stLine : String;
    stAdvisorName : String;
    stCity : String;
    stState : String;
    stZip : String;
    begin
    { Create the advisor name }
    stAdvisorName := ppBrokeragePipeline['ADVISOR_FIRST_NAME'] + ' ' +
    ppBrokeragePipeline['ADVISOR_LAST_NAME'];
    laBrokerageAdvisor.Caption := stAdvisorName;

    { Create the Address }
    stLine := ppBrokeragePipeline['ADVISOR_ADDRESS_1'];

    if (Length(stLine) > 0) then begin
    mBrokerageAdvisorAddress.Lines.Add(stLine);
    end;

    stLine := ppBrokeragePipeline['ADVISOR_ADDRESS_2'];

    if (Length(stLine) > 0) then begin
    mBrokerageAdvisorAddress.Lines.Add(stLine);
    end;

    stCity := ppBrokeragePipeline['ADVISOR_CITY'];
    stState := ppBrokeragePipeline['ADVISOR_STATE'];
    stZip := ppBrokeragePipeline['ADVISOR_ZIP'];

    if (Length(stCity) > 0) then begin
    stLine := stCity + ', ';
    end;

    if (Length(stState) > 0) then begin
    stLine := stLine + stState + ' ';
    end;

    if (Length(stZip) > 0) then begin
    stLine := stLine + stZip;
    end;

    if (Length(stLine) > 0) then begin
    mBrokerageAdvisorAddress.Lines.Add(stLine);
    end;

    end;

    When this report displays the two records in the table, the data-backed
    fields all display their corresponding values correctly but the fields
    that are generated here display the first records' data on both pages.


    MattC

    --- posted by geoForum on http://delphi.newswhat.com
  • edited October 2008
    I stared at it long enough that the answer came to me. I'm using the
    BeforePrint method for the entire report. I should be doing it for the
    detail band only. When I did that, it worked fine.


    MattC

    --- posted by geoForum on http://delphi.newswhat.com
This discussion has been closed.