views:

443

answers:

3

I have a winforms application, when a user runs a report there may be no data to display.

I'd like to intercept the fact that there is no data an instead of showing the blank report, display an error message using .NET.

Is there a property I can check before the report displays?

+1  A: 

If you want to catch it in your form, you would need to have some code in the form perform the same query that the report will perform and see if there are any records returned before loading the report. Then you can show your message box and cancel before the report is loaded.

David Stratton
I was wondering if that was going to be the only way. ugh...
Nathan Koop
+3  A: 

I have not been working with Crystal reports for some years but when I was programing with VB 6 we used to send a recordset to our report so that It would be independent from data access logic.I suppose that there should be a way to send a DataTable to a Crystal Report and you can see if there's any data in DataTable before passing it to Crystal Reports

Beatles1692
true, I'm unfortunately am working with a number of preexisting reports that I'd rather not do too many changes to. I'll look into though, thx
Nathan Koop
A: 

You can use the section expert to add conditional statements to hide sections of the report. I implemented this into the reports I designed. I used a "IsNull" function to determine if a field has data. The new section displays "No Records Found" while the other sections that are normally visible when data is present are suppressed.

Daniel Smektala