Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crystal Report Grouping

Status
Not open for further replies.

OttawaDotNet

IS-IT--Management
Sep 25, 2007
9
CA
Hi All:

I have generated a simple report but I forgot to do grouping based on the column. Is there anyway I can go back and perform grouping, or I have to recreate report. As I remember when I had to go through Report Wizard it did ask me grouping at some point. But if I use Database expert it did not take me to Grouping part.

Also, is there anyway I can use code (C# or VB) using crsytalReportSource or Viewer to do grouping based on what user select.

Help is appreciated

Thanks

 
In Crystal 10, you'll find the Group option under Inserton the menu. Probably the same in all versions, but it helps to say which you are using.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
If you want the group to be based on a user selection, go to the field explorer->parameter->new and create a string parameter {?GroupBy} with options like "Customer ID", "Department", etc. Then also in the field explorer go to formula->new and enter:

select {?GroupBy}
case "Customer ID" : totext({table.CustomerID},0,"")
case "Department" : {table.dept}
case "Date" : totext({table.date},"yyyy-MM-dd")

Insert a group on this formula.

-LB
 
Thanks alot for your help.

I am able to do grouping based on user selection.

Now the problem is that if I do sorting using following code:

CrystalDecisions.CrystalReports.Engine.FieldDefinition FDef;

FDef = CrystalReportSource1.ReportDocument.Database.Tables[0].Fields[6]; << Assume the 6th field is Job Titile >>
CrystalReportSource1.ReportDocument.DataDefinition.SortFields[0].Field = FieldDefinition;

I lose my group.

Can I only have Grouping and Sorting one at a time ?

If I do grouping based on one column but sort it on other column, Now I see grouping done on same columns on which I did Sorting.

Isn't there anyway we can simply set the column as sorting column and user can click the column to sort it ?

Thanks
Nas

 
It looks like you are doing coding in VB or something, and I'm guessing that takes precedence over the grouping/sorting you do directly in CR. If you did the grouping and sorting in CR, the grouping always takes precedence over sorting.

There is supposedly a new CR version about to be announced that allows you to sort based on clicking a column, but currently the only way to do that is through a third-party product like that offered by MilletSoftware ( Ido is a regular contributor here.

-LB
 
Hello:

Yes, I am doing grouping and sorting programmaticaly based on user selection.

So if user select that he or she wants to see grouping based on Student Number, Then I can write code to do grouping on Student Number.

But if now user decides to do sorting on Name , when I do that using code. I see column sorted but on my left Group Tree, Now i see a Group Tree of Student Name not Student Number that I had before.

I thought I will keep the grouping that i had before and sorting will only be doen on column not effecting the grouping.

uumm or maybe I have to do nested grouping ?

 
I can't help you with coding. If you were doing it in CR instead, you could do two group parameters with the same options, with two separate formulas like the one I showed you above. You would insert two groups, one on each formula. If they would want the option of only grouping on the first formula, then set up a default in the second formula like this:

select {?GroupBy2}
case "Customer ID" : totext({table.CustomerID},0,"")
case "Department" : {table.dept}
case "Date" : totext({table.date},"yyyy-MM-dd")
default : ""

If the user chooses "" the grouping will have no impact.

-LB
 

Excellent , that is what I needed to do... It is working the way I wanted..

It always help talking to Gurus , thanks budd





 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top