views:

1762

answers:

2

I have a section in a Crystal Report that I want to suppress. I need to suppress it if there are 0 rows in a particular table in the dataset I am using. How would I do this? The Record Number special field provided appears to be an internal count of records in the report, and does not relate to the rows in the underlying data table.

I am creating the report from C#, but I cannot suppress the section from the code (it doesn't fit the project structure) - I must be able to do it from the report itself. The table concerned is definitely being passed to the report in the dataset, but it contains 0 rows. There must be a way to establish this inside the report itself.....

Can anyone please point me in the right direction?

+2  A: 

In the Crystal Reports designer, view the properties of your section and there should be an option to Suppress, which you can give it a formula to return the appropriate boolean value.

You could then use the Count() function within that formula and (I believe) you can pass the name of your dataset to the Count() function to get the number of rows in that dataset.

I did the same thing on a complex report about 3 months ago but I don't have access to the report any more having changed jobs so I'm sorry I cannot be more specific, but hoepfully this gives you a starting point.

Just had a quick Google - try this.

Andy Shellam
Thanks - it sort of worked, but now I've got another issue because of that. When there are records in the table in question, the report is now repeating the whole details section the same number of times as there are rows in that table....I've also tried playing with a Shared NumberVar inside a subreport to count the rows in the table, and I can successfully suppress the section I want to in the main report, but this technique then fails when there ARE records - it still suppresses the section.I've got a number of tables being used at the detail level, which probably doesn't help....
JamesW
I've had to add a formula to suppress the subsequent rows that I don't want to see. This addition was purely down to the design of my report, so I'll happily mark your reply as the answer. Thanks again.
JamesW
If you're getting a section for every record in your report but you want a summary of the records instead, you need to use the group header and suppress the details. Thanks :)
Andy Shellam
A: 

If the section does only contain database fields and f.e. no text fields, then you could use the setting "Suppress Blank Section" in the "Section Export" (rightclick section) for that section.

As an alternative you could use the following formula in the "Suppress" in the "Section Export" for that section:

IsNull({table.field})

"{table.field}" is one of the fields in the dataset.

Hope this helps.