Unless I am missing something: When a report has a filter and the filter finds no records to include in the detail section, the report preview window will be completely blank. Even text such as the report title or text in a conditional object will not appear. Upon saving or printing the report a generic warning will be the only content of the report and again the title or other text will be suppressed. I have perused the documentation and the message board and the only suggestion I found was to first test the filter and only preview reports were records were found. In the case of no records found then produce another report which simply warns the reader that there is no data. I have done that and find it cumbersome.
The solution is so simple that I can hardly believe it. It uses subreports.
I take a filtered report with a detail section and add a subreport. I remove the detail section from the main report and make it the detail section of the subreport. I leave in the main report only the text which I want to always print even if there is no data, like the title. I remove the filter from the main report and use the same filter for the subreport. Now when there is nothing to include in the detail section, the filtered subreport does not print but the unfiltered main report does print. I often include in the main report a conditional object with a text field, warning the reader that there is no data. If the test for the data is simple then that can be the condition for the conditional object. If the test for the data is complex then I include that test in the onprint event and set a layout variable which I use for the condition for the conditional object. This works well for report previews, saves and printing on the desktop and also works well for web applications where the report is saved and then sent on the web.
Maybe every one else already knew this but just in case I am happy to share such a simple and useful solution to a problem that has been so frustrating for me.
Thanks for reading and for all you help over the years.
Irwin
The solution is so simple that I can hardly believe it. It uses subreports.
I take a filtered report with a detail section and add a subreport. I remove the detail section from the main report and make it the detail section of the subreport. I leave in the main report only the text which I want to always print even if there is no data, like the title. I remove the filter from the main report and use the same filter for the subreport. Now when there is nothing to include in the detail section, the filtered subreport does not print but the unfiltered main report does print. I often include in the main report a conditional object with a text field, warning the reader that there is no data. If the test for the data is simple then that can be the condition for the conditional object. If the test for the data is complex then I include that test in the onprint event and set a layout variable which I use for the condition for the conditional object. This works well for report previews, saves and printing on the desktop and also works well for web applications where the report is saved and then sent on the web.
Maybe every one else already knew this but just in case I am happy to share such a simple and useful solution to a problem that has been so frustrating for me.
Thanks for reading and for all you help over the years.
Irwin
Comment