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

No Data Label...

edited May 2002 in General
Hi all...

I have a small problem and would know if there is a way to solve it:

I have some reports which hide certain records, as I can't use a query all
the time to get what I want. This all works fine, except that the "No
Records" label is not shown on those reports most of the time, because the
query actually produces records, they are just not shown.

I found 50% of the solution already, as I create an invisible Variable lable
at run-time to determine how many records where printed during the first
pass. The problem I have now is, that I want to trigger my "No Data"
function to display the label on the empty page, but it seems, that I can't
do anything on the page after it was printed.

How can I place this label after the report is finished printing on screen?

Thanks in advance, Marco...
-----------------------------------------------------------
QUMAS
Enterprise Compliance Management
Visit our Website: http://www.qumas.com

Comments

  • edited May 2002
    You can add a TppDrawtext draw command to the page in the Report.OnEndPage
    event. For an example of addign a draw command to a page see this example:

    http://www.digital-metaphors.com/tips/AddDrawCommandToPage.zip

    Cheers,

    Jim Bennett
    Digital Metaphors

  • edited May 2002
    Hi Jim...

    Thanks for the reply, but unfortunatly it doesn't work. Here's my code:

    procedure TFReportViewer.OnEndPage(Sender: TObject);
    var
    lDrawText: TppDrawText;
    a,b : Boolean;
    begin
    if VisibleDetailCount = 0 then begin
    lDrawText := TppDrawText.Create(nil);
    lDrawText.Page := Report.Engine.Page;
    ReportNoData(Self, nil, a, lDrawText, b);
    end;
    end;

    procedure TFReportViewer.ReportNoData(Sender, aDialog: TObject;
    var aShowDialog: Boolean; aDrawCommand: TObject;
    var aAddDrawCommand: Boolean);
    var lDrawText : TppDrawText;
    begin
    lDrawText := TppDrawText(aDrawCommand);
    with lDrawText do begin
    TextAlignment := taCentered;
    Font.Style := [fsBold, fsUnderline, fsItalic];
    Font.Color := clBlue;
    Font.Size := 14;
    Text := 'There are no records matching your search criteria...';
    Left := 0;
    Width := Report.PrinterSetup.PageDef.mmPrintableWidth;
    end;
    end;

    The code gets executed, but it never prints on screen. Any ideas?

    TIA, Marco...
    -----------------------------------------------------------
    QUMAS
    Enterprise Compliance Management
    Visit our Website: http://www.qumas.com


  • edited May 2002
    This works in the Report.OnEndPage event:

    procedure TForm1.ppReport1EndPage(Sender: TObject);
    var
    lDrawText: TppDrawText;
    begin

    lDrawText := TppDrawText.Create(Self);
    lDrawText.Page := ppReport1.Engine.Page;
    lDrawText.Text := 'No Data';
    lDrawText.Top := ppReport1.PrinterSetup.PageDef.mmPrintableHeight div 2;
    lDrawText.Left := ppReport1.PrinterSetup.PageDef.mmPrintableWidth div 2;
    lDrawText.Height := 12700;
    lDrawText.Width := 25400;
    lDrawText.Font.Color := clBlack;
    lDrawText.Font.Size := 12;
    lDrawText.Font.Name := 'Arial';

    end;


    Cheers,

    Jim Bennett
    Digital Metaphors

This discussion has been closed.