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

Mailing labels one at a time

edited August 2002 in General
I want to use a report to print mailing labels. I have created a report
using columns etc. to match the layout of the A4 sheet of labels and
connected this to a datapipline. Usually I only want to print one label (for
the current record in the DB) of all the ones on the sheet. By limiting the
range of the datapline to the current record I can get the report to show
one label.

At the moment this one label is always the first on the sheet. How can I
best control the report (via user input - user knowing that they just put a
partly used sheet of labels in the printer) to print the label in a
specified location or the many ion the sheet?

Comments

  • edited August 2002
    You'll need to use the label skip technique. Here is the example code since
    our ftp server is down:

    This demo has an edit box for the number of labels to skip and a button to
    print in its OnClick event handler.

    TForm1...
    ...
    private
    FSkip: Integer;
    FTotalBandsPerColumn: Integer;
    public
    { Public declarations }
    end;

    var
    Form1: TForm1;

    implementation

    {$R *.DFM}

    procedure TForm1.Button1Click(Sender: TObject);
    begin
    FSkip := StrToInt(Edit1.Text) + 1;
    FTotalBandsPerColumn := 0;

    ppReport1.DetailBand.BandsPerRecord := FSkip;

    ppDBCalc1.Visible := False;
    ppDBText1.Visible := False;

    ppReport1.Print;
    end;

    procedure TForm1.ppDetailBand1BeforePrint(Sender: TObject);
    begin
    if ((((ppReport1.CurrentColumn - 1) * FTotalBandsPerColumn) +
    ppReport1.DetailBand.Count) = (FSkip - 1)) then
    begin
    ppReport1.DetailBand.BandsPerRecord := 1;

    ppDBCalc1.Visible := True;
    ppDBText1.Visible := True;
    end;
    end;

    procedure TForm1.ppReport1EndColumn(Sender: TObject);
    begin
    if (FTotalBandsPerColumn = 0) then
    FTotalBandsPerColumn := ppReport1.DetailBand.Count;
    end;


    Cheers,

    Jim Bennett
    Digital Metaphors

  • edited August 2002
    Thanks Jim for pointing me in the right direction.

    Small additions: when printing from screen preview this skipping does not
    work. So I have moved the processing from the button onclick to the report
    BeforePrint event. I also looped through all the controls in the detail band
    to make them invisible.

    Sarah


This discussion has been closed.