Print Page | Close Window

Creating A Formula To Create Groups

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=8644
Printed Date: 05 May 2024 at 1:02pm


Topic: Creating A Formula To Create Groups
Posted By: AdamA
Subject: Creating A Formula To Create Groups
Date Posted: 15 Dec 2009 at 1:31pm
Ok, this one sounds pretty simple, but has proven itself to be trickier than I thought.
 
I have 4 subreports in Details A-D with no database connected for the main report (using it only as a container).  I need to have the Group Tree created, so a user can easily navigate to the beginning of each subreport (as I would conditionally suppress the Details Section/subreport when it did not match the appropriate Group Name).
 
So in essence, I'm looking to display things in the following manner --
 
GROUP NAME 01
--------
SubReport 01
===================
GROUP NAME 02
--------
SubReport 02
===================
etc
 
with a Group Tree indicating each Group
 
The catch being, there are no fields to base a formula on in the main report.
 
I've tried the following formula (which, while valid, is not selectable for the Group By function):
 
StringVar ReportName;
NumberVar X;
For X:= 1 to 4 Step 1 do
(If X = 1 Then "Group 01"
Else If X = 2 Then "Group 02"
Else If X = 3 Then "Group 03"
Else If X = 4 Then "Group 04");
 
Any assistance would be greatly appreciated   :)
 
Thank you!
 
 
 



Replies:
Posted By: lockwelle
Date Posted: 16 Dec 2009 at 6:14am
without a field in the main report, no grouping is possible.  CR cannot determine before the report is rendered what data goes in what group.
 
Data for grouping must exist in the data. It might be a manipulation or a simple calculation, but all of pieces of the group criteria must exist/be deterministic before the report is rendered.  Subreports don't 'exist' prior to rendering. This is what I have figured out by playing with CR and trying out various dynamic grouping formulas.
 
just as a last note: why do you have ReportName in the above snippet, it is not used?
 
HTH


Posted By: AdamA
Date Posted: 16 Dec 2009 at 6:28am
The subreports are just separate stand-alone reports, no connection to each other or the main report, they just need to be run together.  I know this is possible, as I have done it before, but that was years ago - I am now at another company and don't have access to my prior work.
 
I am certain that one can create a formula to group on without using a field.
 


Posted By: AdamA
Date Posted: 17 Dec 2009 at 2:23pm
I guess I should have specified more clearly that there is no data in the main report (and no database associated with it either) - I can associate the main database that is used for the 4 subreports with the main report, but there is no field linking to any of the subreports, and there is no field in the database that will define the grouping I am looking to get - it has to be done on a formula without using a field.



Print Page | Close Window