Displaying special message in detail band
Hello,
I have a Master-Detail report in OnNoData I print a special message to the
report when there is no data available. This works fine. But in the detail
band of the child report on the BeforePrint event I set the visibility of
the detail band based on a set of filters the user can set and if the
message that goes in the detail band is one the user does not want to see I
set the visibility of the detail band to false and if it is a message the
user wants to see I set the visibility to true. The problem is when the
only messages that get returned by the query are all ones the use does not
want to see I do not get a message on the screen saying no data available
(or all messages filtered out).
How can I determine if all the messages have been filtered out and I need to
display my special text?
Is there a better way to do what I'm doing? There are a large number of
filters so trying to only retrieve messages the user wants to see via the
query would be impossible.
Thanks in advance,
Rodger Van Kirk
I have a Master-Detail report in OnNoData I print a special message to the
report when there is no data available. This works fine. But in the detail
band of the child report on the BeforePrint event I set the visibility of
the detail band based on a set of filters the user can set and if the
message that goes in the detail band is one the user does not want to see I
set the visibility of the detail band to false and if it is a message the
user wants to see I set the visibility to true. The problem is when the
only messages that get returned by the query are all ones the use does not
want to see I do not get a message on the screen saying no data available
(or all messages filtered out).
How can I determine if all the messages have been filtered out and I need to
display my special text?
Is there a better way to do what I'm doing? There are a large number of
filters so trying to only retrieve messages the user wants to see via the
query would be impossible.
Thanks in advance,
Rodger Van Kirk
This discussion has been closed.
Comments
Not sure that I completely understand the question, but I was able to create
a simple example. I created a variable
var
gNoData: Boolean;
In the childreport OnStartFirstPass event I initialize it
gNoData := True;
In the childreport DetailBand BeforePrint event, I set it to false if the
band is visible
if {filter logic} then
Report.DetailBand.Visible := False
else
Report.DetailBand.Visible := True;
if Report.DetailBand.Visible then
gNoData := False;
I added a TppLabel to the childreport SummaryBand with a caption of 'No
Data'. In the SummaryBand BeforeGenerate event I toggle the visibility
lblNoData.Visible := gNoData;
--
Nard Moseley
Digital Metaphors Corporation
www.digital-metaphors.com
Best regards,
Nard Moseley
Digital Metaphors
www.digital-metaphors.com
This appears to have done exactly what I wanted.
Thanks,
Rodger Van Kirk
I came across one problem when printing this report on several customers.
If the customer has data it prints ok.
If all the data is filtered out everything prints ok.
But if there is no data available for this customer both the "Data filtered
out of view" message (described below) and the "No data available" message
created in the OnNoData event are displayed. I stepped through the code and
found that the BeforeGenerate event for the summary band gets fired before
the OnNoData event so I can not simply set the gNoData := False in the
OnNoData event. I believe the following code will fix my problem but I'm
not sure what property to look at.
If I modify the BeforeGenerate of the summary band to something like this:
lblNoData.Visible := (gNoData) and (ppChildReport.RecordCount > 0);
ppChildReport.RecordCount property does not exist but I was wondering if
there was something like that, that I could use to determine if the OnNoData
event is going to fire off?
Thanks in advance,
Rodger Van Kirk
You can use the following...
if Report.DataPipeline.Bof and Report.DataPipeline.Eof then
{no records in dataset}
else
{the dataset contains at least one record}
Note: In Delphi, the TDataSet has a RecordCount property. However
referencing this property can cause a huge slowdown in performance - it
causes all records to be sent over the network from the database to the
client machine. Therefore RB avoids using it.
--
Nard Moseley
Digital Metaphors Corporation
www.digital-metaphors.com
Best regards,
Nard Moseley
Digital Metaphors
www.digital-metaphors.com