Currently, the default behavior for a custom report is to do nothing when no data has been found.


To change this behavior, you have to manually modify a property in the RTM file that IndySoft creates.

1) Save the Custom Report as Text
2) Edit the top of the report to contains something similar to the following:

object ppCustomReport: TppReport
AutoStop = False
DataPipeline = daODACQueryDataView1.Gages
NoDataBehaviors = [ndMessageOnPage, ndBlankReport] <-- NEW LINE

Here are the 4 types of behaviors - the default is ndBlankPage

ndBlankPage The default behavior. No page is generated or sent to the devices. As a result, the standard Print Preview form will display a single blank page, and status bar will read 'Page 0.' If the report is a subreport, the engine will simply exit, without using any page space or adding any draw commands to the page.
ndBlankReport The report generates as it normally would and the resulting page is sent to the devices. The detail band generates only once, creating the effect of an 'empty' report, where all the data aware components are blank and all formatting components (shapes, lines, labels, etc.) display as normal.
ndMessageOnPage A text label is centered on the output page, which reads 'No Data Found.' The draw command used to display this message is passed via the OnNoData event so that the message can be further customized if necessary. MessageOnPage is only available in conjunction with BlankReport. Since no page is generated when using BlankPage, it iS not possible to display text messages when using this option. Note: When this behavior is used for fixed or child-type subreports, the text message is centered in the space used by the subreport. Because the message simply says 'No Data Found.', you may want to customize it when used in the context of a subreport, see OnNoData for more on this.
ndMessageDialog A modal dialog is displayed. By default, this dialog simply says: 'No data found for report.'. The dialog can be replaced with a customized version using the form registration scheme. The standard dialog can be found in ppNoDataDlg.pas. Note: This option is usually not useful in the context of subreports, since the dialog is displayed each time a subreport encounters a no data situation. Depending on what you are trying to do, it may make sense to customize TppNoDataDialog for use in the subreport context.


3) Then re-load the report from Text
4) with ndBlankReport + ndMesageOnPage , you can do the following type of items inside your report:

OnNoData Event for the Report
------------------------------

How to print static text that is centered to page:

Var
lDrawText : TppDrawText;
begin
lDrawText := TppDrawText(aDrawCommand);
lDrawText.TextAlignment := taCentered;
lDrawText.Text := 'YOUR CUSTOM TEXT HERE';
lDrawText.Left := 0.0;
lDrawText.Width := Report.PrinterSetup.PaperWidth;


This event fires when no data is found by the data pipeline connected to a report. The behaviors indicated by the NoDataBehaviors property determines which parameters contain values.
If the MessageOnPage option has been selected, then the draw text command which will be added to the output page is passed via the aDrawCommand parameter (otherwise this parameter is nil.) You can prevent the draw command from being added to the output page by setting aAddDrawCommand to False. Doing so causes the draw command to be freed by the engine. In order to get access to the draw command properties, add ppDrwCmd to the uses clause, and typecast this parameter as TppDrawText. You can then set the value and position of the text, as in:

5) With ndBlankReport + ndMessageDialog - a Message Box will appear when the report is blank


Things to be aware when following this process – It's been noticed that the subsequent import from text file is extremely erratic. It may throw a number of errors at times about invalid strings, invalid stream, invalid procedure, etc. You sometimes have to import from text 5 or 6 times before it reports that it was imported successfully. At times you may have to delete the report completely and start the process of importing from file (as text) all over again to get past the errors.