Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: Sort on field in Subreport Post Reply Post New Topic
Author Message
Vack
Newbie
Newbie


Joined: 22 Oct 2008
Location: United States
Online Status: Offline
Posts: 24
Quote Vack Replybullet Topic: Sort on field in Subreport
    Posted: 23 Jun 2009 at 9:26am
I have a subreport that returns a date on my main report. Is it possible to sort on the value that is returned by my subreport?
IP IP Logged
Takesen
Senior Member
Senior Member


Joined: 29 Dec 2008
Location: United States
Online Status: Offline
Posts: 143
Quote Takesen Replybullet Posted: 23 Jun 2009 at 12:26pm

Just an idea, I believe it should work...

if you create a shared variable (would be eiter datetimevar or datevar)

make it
 
shared datetimevar := {datetime_field}
 
throw this into your main report and group by it. you can suppress the group header and footer if you don't want to see them.
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 24 Jun 2009 at 6:20am
absolutely should work.
IP IP Logged
Vack
Newbie
Newbie


Joined: 22 Oct 2008
Location: United States
Online Status: Offline
Posts: 24
Quote Vack Replybullet Posted: 24 Jun 2009 at 9:31am
When I go to group it the formula field is not an option to group by. That Doesn't seem to work.
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 24 Jun 2009 at 10:43am
OK, in the subreport you have a formula like:
shared datetimevar  aVar := {table.field}
 
in the main report you have a formula like:
shared datetimevar aVar
 
if this is the setup, I don't know, since you should be able to group on the formula name that is located in the main report.  I group on formulas all the time.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 24 Jun 2009 at 12:10pm

Is this an issue of evaulation processes?

Can one sort or group on a field that has not been determined until the records are printed?
IP IP Logged
Takesen
Senior Member
Senior Member


Joined: 29 Dec 2008
Location: United States
Online Status: Offline
Posts: 143
Quote Takesen Replybullet Posted: 24 Jun 2009 at 1:38pm
If Dblank's case is correct,
You need to make a copy of the subreport and place it in the report header. (You cannot suppress this subreport, instead make it as small as possible and all the fonts white).
 
You'll pull you're shared variable off that, and it should be able to be used without any issues.
 
-Takesen
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 25 Jun 2009 at 5:46am
Yeah, DBlank, you might be right.  Hadn't thought of the subreport aspect, as I generally don't use them, but depending on how the subreport/report is structured Takesen's solution may not work either as the fields may not be available.  I think that the report can be suppressed, but the problem is going to be that the report....
 
Guys, I think that we have been barking up the wrong tree, could be wrong, but the subreport is returning a date...just a date and he wants to sort on it...that's not really grouping, but at the same time, you can't sort the main report's data based on a subreport value, and placing the subreport in the header isn't do it either.
 
The most efficient way to accomplish this is to have the sort criteria in the main report's data...either stored proc/view or join the data (which might cause duplicates).  Of course I vote for stored procs, because they give you the flexibility to do this sort of this, as well as bring in the data for the subreport all in one row.  then it is just a matter of displaying, but at the very least a sort date field could be added to the row.
 
Now the reason that I changed my mind is of how I think of Crystal working....it reads a row of data for the main report/formats it, then if it needs to it reads the subreport data/formats it, and reads the next row...DBlank is right, it doesn't know the sort value until tool late.
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.015 seconds.