PC Review


Reply
Thread Tools Rate Thread

Suppressing Crystal report detail section at runtime

 
 
Bill Nguyen
Guest
Posts: n/a
 
      7th Oct 2003
I have the need to suppress a Crystal report detail section at runtime (when
user selects "Summary" instead of "Detail"). The report created in CR 8.5
and loaded using .ReportDocument . I couldn't find anything in
ReportDocument control regarding this function.
Any suggestion is greatly appreciated.
Bill


 
Reply With Quote
 
 
 
 
Armin Zingler
Guest
Posts: n/a
 
      7th Oct 2003
"Bill Nguyen" <(E-Mail Removed)> schrieb
> I have the need to suppress a Crystal report detail section at
> runtime (when user selects "Summary" instead of "Detail"). The report
> created in CR 8.5 and loaded using .ReportDocument . I couldn't find
> anything in ReportDocument control regarding this function.
> Any suggestion is greatly appreciated.
> Bill


A CrystalDecisions.CrystalReports.Engine.ReportDocument object has a
ReportDefinition property. It returns a
CrystalDecisions.CrystalReports.Engine.ReportDocument.ReportDefinition
object. The object has a Sections property. You can use a loop to process
the sections. A section has a Kind property. The section that's "Kind"
property is AreaSectionKind.Detail is the detail section.

Or: When you create an instance of your derived ReportDocument, each section
is added as a property. If you rename the detail section to "detail", you
can access the section: MyDocument.Detail.

The Sectionformat property of a Section object has a EnableSuppress
property. You can set it to True to suppress the section.


--
Armin

 
Reply With Quote
 
 
 
 
Bill Nguyen
Guest
Posts: n/a
 
      8th Oct 2003
Armin;
Thanks for the tip.
I used ReportDocument and it worked. However, there are some problems
associated with this:

You have to treat each report differently depending on the number of
sections you have in it. There is no universal section name/label that you
can use. For example, I have 1 report with 7 sections, another with 9 (I use
sections.count to display the sections). The section count includes
suppressed and non-suppressed sections. The .Sections(x), however, only
counts non-suppressed sections. I don't know of any way to get section
name/label so that I can just use the following code:

reportDocument1.ReportDefinition.Sections("SECTION_NAME").SectionFormat.Enab
leSuppress = True



If this is possible, I can just label the section following a naming
convention for all of my reports and the code will work for all of them.

Thanks

Bill



"Armin Zingler" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "Bill Nguyen" <(E-Mail Removed)> schrieb
> > I have the need to suppress a Crystal report detail section at
> > runtime (when user selects "Summary" instead of "Detail"). The report
> > created in CR 8.5 and loaded using .ReportDocument . I couldn't find
> > anything in ReportDocument control regarding this function.
> > Any suggestion is greatly appreciated.
> > Bill

>
> A CrystalDecisions.CrystalReports.Engine.ReportDocument object has a
> ReportDefinition property. It returns a
> CrystalDecisions.CrystalReports.Engine.ReportDocument.ReportDefinition
> object. The object has a Sections property. You can use a loop to process
> the sections. A section has a Kind property. The section that's "Kind"
> property is AreaSectionKind.Detail is the detail section.
>
> Or: When you create an instance of your derived ReportDocument, each

section
> is added as a property. If you rename the detail section to "detail", you
> can access the section: MyDocument.Detail.
>
> The Sectionformat property of a Section object has a EnableSuppress
> property. You can set it to True to suppress the section.
>
>
> --
> Armin
>



 
Reply With Quote
 
Armin Zingler
Guest
Posts: n/a
 
      8th Oct 2003

"Bill Nguyen" <(E-Mail Removed)> schrieb im Newsbeitrag
news:(E-Mail Removed)...
> Armin;
> Thanks for the tip.
> I used ReportDocument and it worked. However, there are some problems
> associated with this:
>
> You have to treat each report differently depending on the number of
> sections you have in it. There is no universal section name/label that you
> can use. For example, I have 1 report with 7 sections, another with 9 (I

use
> sections.count to display the sections). The section count includes
> suppressed and non-suppressed sections. The .Sections(x), however, only
> counts non-suppressed sections.


I can't repro this. The Sections property contains all sections, no matter
if suppressed or not. I used the following code:

Dim rpt As New CrystalReport2
Dim sec As CrystalDecisions.CrystalReports.Engine.Section

Debug.WriteLine("Before suppressing detail section:")
Debug.WriteLine(rpt.ReportDefinition.Sections.Count())

For Each sec In rpt.ReportDefinition.Sections
Debug.WriteLine(sec.Name)
Next

rpt.detail.SectionFormat.EnableSuppress = True

Debug.WriteLine("After suppressing detail section:")
Debug.WriteLine(rpt.ReportDefinition.Sections.Count())

For Each sec In rpt.ReportDefinition.Sections
Debug.WriteLine(sec.Name)
Next


Output:

Before suppressing detail section:
5
Section1
Section2
detail
Section4
Section5
After suppressing detail section:
5
Section1
Section2
detail
Section4
Section5


> I don't know of any way to get section
> name/label so that I can just use the following code:
>
>

reportDocument1.ReportDefinition.Sections("SECTION_NAME").SectionFormat.Enab
> leSuppress = True


This works for me:
rpt.ReportDefinition.Sections("detail").SectionFormat.EnableSuppress = True


> If this is possible, I can just label the section following a naming
> convention for all of my reports and the code will work for all of them.


I'm not a fan of "late binding". Means, if one of your report (mistakenly)
has a different name, or you wrote the wrong section name in your code, the
compiler can't find this error, whereas using the typed reference using
"report.detail." can be checked at compile time. But that's up to you, I can
only say that the code above worked for me.

--
Armin

 
Reply With Quote
 
BenoitM
Guest
Posts: n/a
 
      8th Oct 2003
hi !

the simplest way is to create a boolean parameter and use this param inside the 'supress' property
of your detail section (using a formula)

"Bill Nguyen" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> I have the need to suppress a Crystal report detail section at runtime (when
> user selects "Summary" instead of "Detail"). The report created in CR 8.5
> and loaded using .ReportDocument . I couldn't find anything in
> ReportDocument control regarding this function.
> Any suggestion is greatly appreciated.
> Bill
>
>



 
Reply With Quote
 
Bill Nguyen
Guest
Posts: n/a
 
      8th Oct 2003
Thanks a lot, Armin.
I'll try this and let you know.
Bill

"Armin Zingler" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
>
> "Bill Nguyen" <(E-Mail Removed)> schrieb im Newsbeitrag
> news:(E-Mail Removed)...
> > Armin;
> > Thanks for the tip.
> > I used ReportDocument and it worked. However, there are some problems
> > associated with this:
> >
> > You have to treat each report differently depending on the number of
> > sections you have in it. There is no universal section name/label that

you
> > can use. For example, I have 1 report with 7 sections, another with 9 (I

> use
> > sections.count to display the sections). The section count includes
> > suppressed and non-suppressed sections. The .Sections(x), however, only
> > counts non-suppressed sections.

>
> I can't repro this. The Sections property contains all sections, no matter
> if suppressed or not. I used the following code:
>
> Dim rpt As New CrystalReport2
> Dim sec As CrystalDecisions.CrystalReports.Engine.Section
>
> Debug.WriteLine("Before suppressing detail section:")
> Debug.WriteLine(rpt.ReportDefinition.Sections.Count())
>
> For Each sec In rpt.ReportDefinition.Sections
> Debug.WriteLine(sec.Name)
> Next
>
> rpt.detail.SectionFormat.EnableSuppress = True
>
> Debug.WriteLine("After suppressing detail section:")
> Debug.WriteLine(rpt.ReportDefinition.Sections.Count())
>
> For Each sec In rpt.ReportDefinition.Sections
> Debug.WriteLine(sec.Name)
> Next
>
>
> Output:
>
> Before suppressing detail section:
> 5
> Section1
> Section2
> detail
> Section4
> Section5
> After suppressing detail section:
> 5
> Section1
> Section2
> detail
> Section4
> Section5
>
>
> > I don't know of any way to get section
> > name/label so that I can just use the following code:
> >
> >

>

reportDocument1.ReportDefinition.Sections("SECTION_NAME").SectionFormat.Enab
> > leSuppress = True

>
> This works for me:
> rpt.ReportDefinition.Sections("detail").SectionFormat.EnableSuppress =

True
>
>
> > If this is possible, I can just label the section following a naming
> > convention for all of my reports and the code will work for all of them.

>
> I'm not a fan of "late binding". Means, if one of your report (mistakenly)
> has a different name, or you wrote the wrong section name in your code,

the
> compiler can't find this error, whereas using the typed reference using
> "report.detail." can be checked at compile time. But that's up to you, I

can
> only say that the code above worked for me.
>
> --
> Armin
>



 
Reply With Quote
 
Bill Nguyen
Guest
Posts: n/a
 
      9th Oct 2003
Benoit;
I created a parameter "p_suppress" in the report and used the following
codes (from Brian's CR book online webpage). Got error
"CrystalDecisions.Shared - Invalid Object type"
What did I do wrong?
Thanks
Bill
--------------------

dim rptSum as boolean
*** actually, rptSUM is passed from the calling sub.

reportDocument1.Load(crRptName)

Dim ParameterFields As CrystalDecisions.Shared.ParameterFields

Dim ParameterField As CrystalDecisions.Shared.ParameterField

ParameterFields = New CrystalDecisions.Shared.ParameterFields

ParameterField = New CrystalDecisions.Shared.ParameterField

ParameterField.ParameterFieldName = "p_suppress"

ParameterField.CurrentValues.Add(rptSum)

ParameterFields.Add(ParameterField)

With myCrystal.CrystalReportViewer1

..ReportSource() = reportDocument1

..SelectionFormula = mSelection

..ParameterFieldInfo = ParameterFields

..RefreshReport()

End With

"BenoitM" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> hi !
>
> the simplest way is to create a boolean parameter and use this param

inside the 'supress' property
> of your detail section (using a formula)
>
> "Bill Nguyen" <(E-Mail Removed)> wrote in message

news:(E-Mail Removed)...
> > I have the need to suppress a Crystal report detail section at runtime

(when
> > user selects "Summary" instead of "Detail"). The report created in CR

8.5
> > and loaded using .ReportDocument . I couldn't find anything in
> > ReportDocument control regarding this function.
> > Any suggestion is greatly appreciated.
> > Bill
> >
> >

>
>



 
Reply With Quote
 
Bill Nguyen
Guest
Posts: n/a
 
      9th Oct 2003
Found problem! I forgot to add the discretevalue .
now I have a new problem, The report still prompts for the value of
p_suppress (True or False). In VB6, you can suppress it. I just don't know
how to do it in VB.NET.
Please help.
Thanks
Bill

"Bill Nguyen" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Benoit;
> I created a parameter "p_suppress" in the report and used the following
> codes (from Brian's CR book online webpage). Got error
> "CrystalDecisions.Shared - Invalid Object type"
> What did I do wrong?
> Thanks
> Bill
> --------------------
>
> dim rptSum as boolean
> *** actually, rptSUM is passed from the calling sub.
>
> reportDocument1.Load(crRptName)
>
> Dim ParameterFields As CrystalDecisions.Shared.ParameterFields
>
> Dim ParameterField As CrystalDecisions.Shared.ParameterField
>
> ParameterFields = New CrystalDecisions.Shared.ParameterFields
>
> ParameterField = New CrystalDecisions.Shared.ParameterField
>
> ParameterField.ParameterFieldName = "p_suppress"
>
> ParameterField.CurrentValues.Add(rptSum)
>
> ParameterFields.Add(ParameterField)
>
> With myCrystal.CrystalReportViewer1
>
> .ReportSource() = reportDocument1
>
> .SelectionFormula = mSelection
>
> .ParameterFieldInfo = ParameterFields
>
> .RefreshReport()
>
> End With
>
> "BenoitM" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > hi !
> >
> > the simplest way is to create a boolean parameter and use this param

> inside the 'supress' property
> > of your detail section (using a formula)
> >
> > "Bill Nguyen" <(E-Mail Removed)> wrote in message

> news:(E-Mail Removed)...
> > > I have the need to suppress a Crystal report detail section at runtime

> (when
> > > user selects "Summary" instead of "Detail"). The report created in CR

> 8.5
> > > and loaded using .ReportDocument . I couldn't find anything in
> > > ReportDocument control regarding this function.
> > > Any suggestion is greatly appreciated.
> > > Bill
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
BenoitM
Guest
Posts: n/a
 
      10th Oct 2003
You can use the 'SetParameterValue' method of the ReportDocument object to pass param infos more
easily ...


"Bill Nguyen" <(E-Mail Removed)> wrote in message news:%(E-Mail Removed)...
> Found problem! I forgot to add the discretevalue .
> now I have a new problem, The report still prompts for the value of
> p_suppress (True or False). In VB6, you can suppress it. I just don't know
> how to do it in VB.NET.
> Please help.
> Thanks
> Bill
>
> "Bill Nguyen" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Benoit;
> > I created a parameter "p_suppress" in the report and used the following
> > codes (from Brian's CR book online webpage). Got error
> > "CrystalDecisions.Shared - Invalid Object type"
> > What did I do wrong?
> > Thanks
> > Bill
> > --------------------
> >
> > dim rptSum as boolean
> > *** actually, rptSUM is passed from the calling sub.
> >
> > reportDocument1.Load(crRptName)
> >
> > Dim ParameterFields As CrystalDecisions.Shared.ParameterFields
> >
> > Dim ParameterField As CrystalDecisions.Shared.ParameterField
> >
> > ParameterFields = New CrystalDecisions.Shared.ParameterFields
> >
> > ParameterField = New CrystalDecisions.Shared.ParameterField
> >
> > ParameterField.ParameterFieldName = "p_suppress"
> >
> > ParameterField.CurrentValues.Add(rptSum)
> >
> > ParameterFields.Add(ParameterField)
> >
> > With myCrystal.CrystalReportViewer1
> >
> > .ReportSource() = reportDocument1
> >
> > .SelectionFormula = mSelection
> >
> > .ParameterFieldInfo = ParameterFields
> >
> > .RefreshReport()
> >
> > End With
> >
> > "BenoitM" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > hi !
> > >
> > > the simplest way is to create a boolean parameter and use this param

> > inside the 'supress' property
> > > of your detail section (using a formula)
> > >
> > > "Bill Nguyen" <(E-Mail Removed)> wrote in message

> > news:(E-Mail Removed)...
> > > > I have the need to suppress a Crystal report detail section at runtime

> > (when
> > > > user selects "Summary" instead of "Detail"). The report created in CR

> > 8.5
> > > > and loaded using .ReportDocument . I couldn't find anything in
> > > > ReportDocument control regarding this function.
> > > > Any suggestion is greatly appreciated.
> > > > Bill
> > > >
> > > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
New Member
Join Date: Jun 2012
Posts: 1
 
      6th Jun 2012
I want to suppress whole detail section if my group is suppressed. I suppressed group on this condition: if purchase date > the date entered in parameter field.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
suppressing line feeds in the detail part of a report John MilburySteen Microsoft Access Reports 1 1st Feb 2009 04:00 AM
Skip one detail report in a report detail section? foxhsu via AccessMonster.com Microsoft Access Reports 1 29th Sep 2005 04:20 PM
Tabbing from 'Header' section to 1st field in 'Detail' section? =?Utf-8?B?UGF0IERvb2xz?= Microsoft Access Forms 3 29th Jan 2005 10:27 PM
Need to display column name on detail section of a crystal report. Meena Microsoft VB .NET 3 28th Apr 2004 08:52 AM
Menu_id Header section vs. Detail Section...help ann smith Microsoft Access Reports 4 2nd Dec 2003 07:34 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:33 AM.