NoData behavior
Is there any way to detect that the report has no any pages before actually printing?
In other words I need to know if report has data even before preview window appear.
I don't want to allow user print or save blank pages ([ndBlankPage]).
For now I did this like:
Could You help me?
In other words I need to know if report has data even before preview window appear.
I don't want to allow user print or save blank pages ([ndBlankPage]).
For now I did this like:
function ReportHasRecords(AReport: TppReport): boolean; begin AReport.Publisher.CachePages := True; AReport.Publisher.Publish; Result := (AReport.PageCount > 0); AReport.Reset; end; ... if ReportHasRecords(AReport) then AReport.Print else ShowMessage('There is no Data in the Report');But it decrease report execute speed and cause many issues during actually Report print.
Could You help me?
Comments
The Preview toolbar buttons should be disabled when there are no pages for [ndBlankPage].
In testing I found the Export button is not being disabled and the Viewer PopupMenu is still visible. I created a patch for RB 22.03 to resolve the issues. You can email support@ and request the patch.
The Report.AfterOpenDataPipelines event can be used to check for no data. (But with the above in place I don't think it is needed)
Best regards,
Nard Moseley
Digital Metaphors
www.digital-metaphors.com
So if we want to Print this via PDF printer (for example), we will see Printer Dialog, we will be able to set output file name and only after this we will got AfterOpenDataPipelines Event.
In my example above a find the way to do this without actually Report.Print (using AReport.Publisher.Publish). But I have some troubles with complex Reports using this method.
Is there any way to OpenDataPipelines or calculate Report pages without Report.Print?
See my example video for more details:
https://dropmefiles.com/GXJR9
I performed some tests:
- print to preview, toolbar buttons are disabled
- print to printer, no print job is sent to printer
- export to file, no file created
- print to MS Print to PDF driver, empty file
- Print to MS XPS document driver, empty file
The last two are a bug/limitation of the MS drivers.
To work around, you can set Report.CachePages True, create a temp device, print to devices, then check the number of pages.
Example:
Best regards,
Nard Moseley
Digital Metaphors
www.digital-metaphors.com