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

Turning off a detail band.

edited May 2002 in General
I know this must be something very basic but I can't seem to find it in
the manuals or help screens or I'm not looking for the right key word.
(Delphi 6 / RB 6)
On BeforeDetailBandGenerate I do some logic test and find that I do not
want to print the detail band for that particular record -- how do I
turn it off for that one record?
Thanks.

Comments

  • edited May 2002
    I don't know if this is the "proper" way to do it but I did something like
    the following and it worked just fine...

    procedure TProductionReportDlg.ppDetailBand1BeforeGenerate(
    Sender: TObject);
    begin
    if IBQuery2.FieldByName('STOCKNUM').AsString = '1274' then
    IBQuery2.Next;
    end;

    Hope this helps,
    Mark Greenhaw
    President
    Glory Road Enterprises

  • edited May 2002
    Thanks for the suggestion. This almost works for my application, - except
    the last record in the table always prints, even if I skip it. The logic I
    tried skips records in the DetailBandBeforeGenerate until it finds one to
    print or until the table.eof is true.

  • edited May 2002
    Larry,
    set the band.visible prop to false
    cu
    marc

  • edited May 2002
    In the DetailBandBeforeGenerate routine, when I set the DetailBand.Visible to
    false at Table.Eof, if in preview mode, the report briefly displays then the
    data disappears leaving only the headings. After changing to OnePass the report
    the detail displays, but the last record that should not print still prints.
    The last record prints whether generated in print or preview mode. (Printing
    from the preview screen results in a report with headings and no data).
    Using debug I can see that the last record is skipped and at Table.Eof the logic
    does set the DetailBand.visible to false, but it still somehow prints that last
    record.
    Another interesting thing - if I do not set the DetailBand.Visible to True
    outside of the DetailBandBeforeGenerate routine before printing the report
    again, no detail data prints.
    Thanks for the suggestions -- any more ideas?

  • edited May 2002
    Try setting the visibility of the detail band in the BeforeGenerate only:

    if (needtoskip) then
    ppReport1.Detail.Visible := False
    else
    ppReport1.Detail.Visible := True;

    Don't set the visibility to True anywhere else - as this is likely the
    problem...

    --
    Cheers,

    Tom Ollar
    Digital Metaphors Corporation
  • edited May 2002
    I am having a similar problem. Let me see if I can explain it so we can
    find the proper response. :-)

    Table one is a customer record (cusid, name, address, etc.)
    1,Bob,Bob's Address
    2,Jim,Jim's Address
    3,Joe,Joe's Address
    4,Mary,Mary's Address
    5,Sue,Sue's Address

    Table two is a list of things a customer must do (doID, doText)
    1, Bring in Phone Bill
    2, Provide two references
    3, Run a 10k marathon
    4, Milk a cow
    5, whatever... :-)

    table three is a list of things each customer has done or not done (cusid,
    doID, IsFinished)

    1,1,True
    1,2,True
    1,3,False
    3,1,False
    3,2,True
    3,3,True
    3,4,False

    A customer may have some, all, or none of the table two items represented in
    table three and a customer may not even be listed in table three.

    I want the report to print only those items from table two that the cutomer
    in table one has NOT done. If the record is false, or if a record does not
    exist in table three for that customer/doItem, then print the doText. If the
    record is true, don't print it.

    In my particular case it is the detail line of a subreport where the SQL
    from the data pipleline SQL statement is
    "select doText from Table 2". This would print each item in the order
    returned by the SQL statement. in the detail band before generate event for
    the subreport, I am trying to do the following but to no avail...

    procedure TOpenStipDlg.ppDetailBand2BeforeGenerate(Sender: TObject);
    begin
    if ibqLookup.Active then ibqLookup.Close;
    if ibtLookup.Active then ibtLookup.Commit;
    ibqLookup.ParamByName('MasID').AsInteger :=
    ibqList.FieldByName('CusID').AsInteger;
    ibqLookup.ParamByName('SID').AsInteger :=
    ibqSL.FieldByName('SID').AsInteger;
    ibqLookup.Open;
    if ibqLookup.RecordCount > 0 then
    begin
    if ibqLookup.FieldByName('IsFinished').AsString = 'T' then
    ppDetailBand2.Visible := False {if the customer
    has completed it, DON't print it}
    else ppDetailband2.Visible := True; {if the customer
    has not completed it then print it}
    end else ppDetailband2.Visible := True; {if the record does
    not exist, the customer has not completed it so print it}
    end;


    The BeforeGenerate event for this band is only fired TWICE with this code.
    I am printing TWO customers and there are FIVE items in Table2. Shouldn't
    this be fired ten times? One for each item originally set to print?

    Mark Greenhaw
    Vulcan Software Systems


  • edited May 2002
    I moved the code to the DetailBand2.BeforePrint procedure and everthing
    worked perfectly.

    Mark Greenhaw
    Vulcan Software Systems
This discussion has been closed.