how to know if report is blank (empty)
Hi!
I'm using RB Pro 7.05 and Delphi 7
My application load a RTM file, modify its SQL query and show it on a
ppViewer component or Screen device.
Sometimes, the report sql query does not bring any result (empty result),
and the report is blank.
I want to show a message when this occurrs, just to alert the user that the
chosen sql does not bring any result.
Is this possible?
I have been trying the NoDataBehaviour but it seems not to work. The dialog
does not appear when the report is blank.
Is there any other method to detect this?
Thanks!
I'm using RB Pro 7.05 and Delphi 7
My application load a RTM file, modify its SQL query and show it on a
ppViewer component or Screen device.
Sometimes, the report sql query does not bring any result (empty result),
and the report is blank.
I want to show a message when this occurrs, just to alert the user that the
chosen sql does not bring any result.
Is this possible?
I have been trying the NoDataBehaviour but it seems not to work. The dialog
does not appear when the report is blank.
Is there any other method to detect this?
Thanks!
This discussion has been closed.
Comments
In my testing with RB 9.02 setting the NoDataBehaviors property to
ndMessageDialog functions as expected when an empty dataset is connected.
You may also try using the OnNoData event of the Report to perform a custom
action when no data is present.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Thanks for your answer.
I'm using RBuilder 7. No plans for upgrade to version 9.
I think the problem is that the report was not saved with this event
handler.
I explain...
1) I load the RTM file on an 'empty' ppReport. The RTM file was created
maybe a few months ago.
2) On the ppReport 'OnNoData' event, I fire a ShowMessage, just for
testing...
3) When I load the report, if the query returns no data, the report is a
blank page, and no message appears.
I think the problem is that the report was not saved (few months ago) with
this event handler. Could this be the cause?
I will test it on an empty application and give you an answer as soon as
possible.
Ok, with a simple ppReport and a simple ppBDEPipeline (linked to that
ppreport) it works fine.
The problem is that, my ppReport has not a ppBDEpipeline assigned. It is a
simple ppreport used for loading RTM files, with NO pipeline assigned.
The RTM files contains its own sql query. It's the only difference. I think
this could be the reason...
How can I know if the loaded report (with SQL Query) is empty?
Yes, this is the reason you are loosing the event handler. Take a look at
the following article on lost event handlers. You can also work around this
issue using RAP with RB Enterprise.
--------------------------------------------
Article: Troubleshooting Lost Event Handlers
--------------------------------------------
Let's assume you have created a report in Delphi and assign an event
handlers to the OnPreviewFormCreate event of the report. The event is
generated by Delphi as:
procedure TForm1.ppReport1PreviewFormCreate(Sender: TObject);
You then save the report to an RTM file 'Report1.RTM.' The events are
stored as references only, and so the RTM contains:
object ppReport1: TppReport
.
.
OnPreviewFormCreate = ppReport1PreviewFormCreate
end
You then go on to work on a different report. Saving it with under then
name 'Report2.RTM'. Only this time, before you save the report you
change the report component name to: rptOrders. Delphi automatically
updates the event declaration for OnPreviewFormCreate event to:
procedure TForm1.rptOrdersPreviewFormCreate(Sender: TObject);
You then create two buttons on the form, one to load Report1 and
preview, the other to load Report2 and preview. When you run the app
and click Report1, you an error. This is because the Report1.RTM file
contains a reference to ppReport1PreviewFormCreate, a method which no
longer exists (at least with this name) in the form.
One answer is to load all your rtm files into the report component you
will be using for loading. Fix any errors, reassign any events that get
cleared. This will update your rtms to contain the proper event handler
names.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com