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

How do I skip used labels on the sheet?

edited September 2002 in General
If the first 2 labels on the sheet are used, how do I skip to the 3rd label
to start? I have done this when using the JIT pipeline, but then I have
complete control over what's printed and when. How do I do it with the DB
pipeline?

Thanks,

Mike

Comments

  • edited September 2002
    You can use the BandsPerRecord property to trick the report into printing
    blank detailbands:

    unit LSkipMain;

    interface

    uses
    Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
    StdCtrls, ppPrnabl, ppClass, ppCtrls, ppBands, ppDB, ppCache, ppDBPipe,
    ppDBBDE, daDataVw, daQuery, daDBBDE, ppModule, daDatMod, ppComm,
    ppRelatv, ppProd, ppReport, ppStrtch, ppRegion, daSQL, daDataView,
    daQueryDataView, daDataModule;

    type
    TForm1 = class(TForm)
    ppReport1: TppReport;
    ppDetailBand1: TppDetailBand;
    ppDBText1: TppDBText;
    ppDBText2: TppDBText;
    ppDBText3: TppDBText;
    Button1: TButton;
    Label1: TLabel;
    Edit1: TEdit;
    ppRegion1: TppRegion;
    BDEQueryDataView1: TdaBDEQueryDataView;
    procedure Button1Click(Sender: TObject);
    procedure ppDetailBand1BeforePrint(Sender: TObject);
    private
    FSkipLabelCount : Integer;
    protected
    procedure SetSkipLabelCount(const Value: Integer);
    public
    property SkipLabelCount: Integer read FSkipLabelCount write
    SetSkipLabelCount;
    end;

    var
    Form1: TForm1;

    implementation

    {$R *.DFM}

    procedure TForm1.Button1Click(Sender: TObject);
    begin
    SkipLabelCount := StrToInt(edit1.Text);
    ppReport1.Print;
    end;

    procedure TForm1.SetSkipLabelCount(const Value: Integer);
    begin
    if Value > 0 then
    begin
    ppDetailBand1.BandsPerRecord := Value + 1;
    ppRegion1.Visible := False;
    FSkipLabelCount := Value;
    end;
    end;

    procedure TForm1.ppDetailBand1BeforePrint(Sender: TObject);
    begin
    if ppDetailBand1.BandsPerRecord > 1 then
    if ppDetailBand1.BandsPerRecordCount = ppDetailBand1.BandsPerRecord then
    begin
    ppRegion1.Visible := True;
    ppDetailBand1.BandsPerRecord := 1;
    end;
    end;

    end.


    Cheers,

    Jim Bennett
    Digital Metaphors

  • edited September 2002
    I've emailed you the project which works to skip labels here. This approach
    only works for top to bottom detail band column traversal.


    Cheers,

    Jim Bennett
    Digital Metaphors

  • edited September 2002
    Jim,

    I appreciate your help, I just can't get it to work. I'm using RB Pro 6.02
    and Delphi 5 Enterprise.

    Here's my code:

    Thanks,

    Mike

    *************************************

    unit Report;

    interface

    uses
    Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
    ppDB, ppDBPipe, ppBands, ppCtrls, ppEndUsr, ppPrnabl, ppClass, ppCache,
    ppComm, ppRelatv, ppProd, ppReport, Db, AdsData, AdsFunc, AdsTable,
    ADSCNNCT, StdCtrls, Mask, AdvSpin, Buttons, AdvCombo, ppRptExp, ppDBJIT,
    AdvGrid, ppTypes, Grids, BaseGrid, ppDsgnDB, daDatMan, ppStrtch, ppRegion;

    type
    TfrmReport = class(TForm)
    rpt5160: TppReport;
    ppColumnHeaderBand1: TppColumnHeaderBand;
    ppDetailBand1: TppDetailBand;
    ppColumnFooterBand1: TppColumnFooterBand;
    dsg5160: TppDesigner;
    rptCustom: TppReport;
    ppHeaderBand1: TppHeaderBand;
    ppDetailBand3: TppDetailBand;
    ppFooterBand1: TppFooterBand;
    ppColumnHeaderBand2: TppColumnHeaderBand;
    ppDetailBand2: TppDetailBand;
    ppDBText1: TppDBText;
    ppDBText2: TppDBText;
    dbtAddress2: TppDBText;
    dbtCityStateZip: TppDBText;
    ppDBText3: TppDBText;
    ppColumnFooterBand2: TppColumnFooterBand;
    plQuery: TppDBPipeline;
    btnRunReport: TBitBtn;
    edtStart: TAdvSpinEdit;
    ReportExplorer: TppReportExplorer;
    sgdSummary: TAdvStringGrid;
    cntQuery: TAdsConnection;
    adqQuery: TAdsQuery;
    dsQuery: TDataSource;
    ppRegion1: TppRegion;
    ppDBText4: TppDBText;
    dbtGreetingFirstLast1: TppDBText;
    dbtAddress11: TppDBText;
    dbtAddress21: TppDBText;
    dbtCityStateZip1: TppDBText;
    procedure btnRunReportClick(Sender: TObject);
    procedure plQueryTraversal(Sender: TObject);
    procedure ppDetailBand1BeforePrint(Sender: TObject);
    private
    { Private declarations }
    FSkipLabelCount : Integer;
    protected
    procedure SetSkipLabelCount(const Value: Integer);
    public
    { Public declarations }
    property SkipLabelCount: Integer read FSkipLabelCount write
    SetSkipLabelCount;
    end;

    var
    frmReport: TfrmReport;

    implementation

    uses Main;

    {$R *.DFM}

    ////////////////////////////////////////////////////////////////////////////
    /////////

    procedure TfrmReport.btnRunReportClick(Sender: TObject);
    begin
    SkipLabelCount := edtStart.Value;

    cntQuery.IsConnected := False;
    cntQuery.ConnectPath := ExtractFileDir(ParamStr(0)) + '\Data\';

    with adqQuery do begin
    Close;
    SQL.Clear;
    SQL.Add('SELECT SortName, LastName, FirstName,');
    SQL.Add('RTRIM(IFNULL(FirstName,' + QuotedStr('') + ')) + ' +
    QuotedStr(' ') + ' + RTRIM(IFNULL(LastName, ' + QuotedStr('') + ')) AS
    FullName,');
    SQL.Add('Company, Position, Address1, Address2, City, State,
    ZipCode,');
    SQL.Add('RTRIM(City) + ' + QuotedStr(', ') + ' + RTRIM(State) + ' +
    QuotedStr(' ') + ' + RTRIM(ZipCode) AS CityStateZip,');
    SQL.Add('Phone, CellPhone, Fax, EMail, WebSite, Source,
    Comments,');
    SQL.Add('AddDate, ModDate, UserID, Newsletter');
    SQL.Add('FROM Client');
    SQL.Add('WHERE Address1 IS NOT NULL AND Newsletter=True');
    end;

    rpt5160.Print;
    end;

    ////////////////////////////////////////////////////////////////////////////
    /////////

    procedure TfrmReport.SetSkipLabelCount(const Value: Integer);
    begin
    if Value > 0 then
    begin
    ppDetailBand1.BandsPerRecord := Value + 1;
    ppRegion1.Visible := False;
    FSkipLabelCount := Value;
    end;
    end;

    ////////////////////////////////////////////////////////////////////////////
    /////////

    procedure TfrmReport.plQueryTraversal(Sender: TObject);
    begin
    if plQuery.DataSource.DataSet.FieldByName('Address2').AsString = '' then
    dbtCityStateZip1.Top := dbtAddress21.Top
    else
    dbtCityStateZip1.Top := 0.8021;
    end;

    ////////////////////////////////////////////////////////////////////////////
    /////////

    procedure TfrmReport.ppDetailBand1BeforePrint(Sender: TObject);
    begin
    // Skip to the first label on the form
    if ppDetailBand1.BandsPerRecord > 1 then begin
    if ppDetailBand1.BandsPerRecordCount = ppDetailBand1.BandsPerRecord
    then begin
    ppRegion1.Visible := True;
    ppDetailBand1.BandsPerRecord := 1;
    end;
    end;
    end;

    end.
This discussion has been closed.