Tips and Tricks
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Tips and Tricks
Message Icon Topic: Grouping Records at Runtime Post Reply Post New Topic
Author Message
Naveed88
Newbie
Newbie
Avatar

Joined: 09 Sep 2008
Location: India
Online Status: Offline
Posts: 2
Quote Naveed88 Replybullet Topic: Grouping Records at Runtime
    Posted: 10 Sep 2008 at 12:10am
ConfusedConfusedHello every body!!!!

i m Developing a website that requires few but strong reporting (Fully Customized). Here i m using Visual Studio 2005 and it's Crystal report tools

What i want is to Group the records by Selected Field in Option(Radio) Button

for Example this is Data Table

ID    Color     Clarity    Carat

1       D            FL          2.0

2        F            VS1       1.4

3        E          VS2        2.0

      D           VS2       2.0

5        D          FL          1.4

 -=- And

  • Color
  • Clarity
  • Carat

are three options and if i select Color

then record should be Grouped by Color

ID     Color     Clarity    Carat

1        D            FL          2.0

      D         VS2         2.0

5        D          FL           1.4

3        E          VS2         2.0

2        F           VS1        1.4

Similarly for  Clarity and Carat fields

 

Please Help me 

Thanks in Advance



Edited by Naveed88 - 10 Sep 2008 at 12:11am
Regards....
Naveed Anjum 9867374437
web Developer
Mumbai,INDIA.
IP IP Logged
wjzabs
Newbie
Newbie
Avatar

Joined: 16 Mar 2009
Online Status: Offline
Posts: 2
Quote wjzabs Replybullet Posted: 17 Mar 2009 at 5:16am

From your example, I am not sure that you are talking about sorting or grouping, because you are saying "grouping" but your example data shows "sorting".

I also don't know how you are planning to get the results of the user's selection of the desired sort from the radio button into the report.  I will assume that you will use a crystal report parameter, and pass the user's sort preference into the report via a parameter from the VB/C# environment or by having the Crystal Report prompt for this parameter value at runtime. 
 
In either case, I think you can get what you are looking for by adding a string formula field that yields the color, clarity, or carat of the detail record using an "if" statement:
 
if {?opt} = 0 then {TABLE_NAME.Color}
else
if {?opt} = 1 then {TABLE_NAME.Clarity}
else
if {?opt} = 2 then ToText({TABLE_NAME.Carat},"###.00")
else
"?"
 
Then, you can sort or group by this new field.
 
The masking on the Carat field is necessary so that a value of 10 will come after a value if 2.0.  With a field like Carat, maybe you won't see this issue (because > 9 Carats may not occur in your data), but I think you can see the issue - also make sure you have enough #'s, or else 1000 will appear before 200.  If you don't want to guess, you can implement 2 formula fields, one a string and the other a decimal value, and use both to create the groups or sort sequence.
 
Also - when creating formulas, pay attention to EvaluationTime  - I generally use WhilePrintingRecords for all of my formulas, but I do not believe you will need that in this one.


Edited by wjzabs - 17 Mar 2009 at 5:17am
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.035 seconds.