11
Jan
08

Hiding Detail Section In Crystal Reports (.Net)

I’m not a Crystal Report Expert. This article is for newbie only. You can read this article in Indonesian Language too here.

I’ve faced this problem two days ago. If there is any extension data, I have to show it in my report where the number of extension table(s) = extension data.

So, I’ve to put the extension data in a datatable, and locate its fields in Details section of my Crystal Report Designer.

 

Detail Section

 

As its behaviour, when the datatable has 4 records, 4 extension tables printed in my report. When it is 3 records, 3 tables printed.

 

Okay. That’s perfect!! When it is N record(s), N table(s) printed. But I don’t know why. When the datatable empty, N = 0, it printed empty table.

 

 

My boss warned me not to display this extension table template.Warning

 

I’ve browsed report document object properties to find a property which could hide details section, but failed to find the associated property.

 

I’ve googled this problem for hours, but failed to find a solution.

 

So I tried to solve this problem on my own creativity.

 

I made two Crystal Report Template (rpt files): Report.rpt and Report_noExtension.rpt.

 

Report_noExtension.rpt is copied from Report.rpt but with little modification to Detail Section.

Hide a section

Right click on detail section à Section Format à select Details in Section Expert à check Hide (Drill-Down OK) option.

Yeah..!! I can hide this section in Report Designer only.

ATTENTION!! IF YOU CAN DO THIS MODIFICATION IN C# 1.1, PLEASE TELL ME HOW TO DO THAT.

Change this code

Dim rpt As New ReportDocument

rpt.Load(ROOT_RPT + “Report.rpt”)

rpt.SetDataSource(ds)

to be

Dim rpt As New ReportDocument
If datatable.Rows.Count = 0 Then
rpt.Load(ROOT_RPT + “Report_noExtension.rpt”)
Else
rpt.Load(ROOT_RPT + “Report.rpt”)
End If

rpt.SetDataSource(ds)

 


4 Responses to “Hiding Detail Section In Crystal Reports (.Net)”


  1. 1 bond_003
    July 17, 2009 at 10:01 pm

    hey i have a similar problem where i cannot display summary – count when there are no details generated in report. i cannot seem to view reply to the post.

    help!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s


Follow

Get every new post delivered to your Inbox.