Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Returning a value from a subreport Post Reply Post New Topic
Author Message
foxy
Groupie
Groupie
Avatar

Joined: 12 Jul 2007
Online Status: Offline
Posts: 50
Quote foxy Replybullet Topic: Returning a value from a subreport
    Posted: 09 Aug 2007 at 3:28am
I have subreport with some selction criteria which then counts up the number of records displayed.
 
I now want to use this count number in a selection formula in the main report.
 
Is this possible? it doesnt seem to be working, it doesnt recognise the formula field name in the main report.
 
Cheers


Edited by foxy - 09 Aug 2007 at 4:31am
IP IP Logged
jkwrpc
Senior Member
Senior Member


Joined: 19 Jun 2007
Location: United States
Online Status: Offline
Posts: 432
Quote jkwrpc Replybullet Posted: 09 Aug 2007 at 10:41am
I dont know a way to do this. The logic of the report as I understand it is this. The main report records are selected then the subreport records are selected. The subreport is generally linked to the main report by a parameter or field. So if that is true then logically the count you want does not exist at the time the data for the main report is selected.
 
There a couple of way to get your count into the main report data query using SQL.  The most common would be through a join and/or a subSelect statement.
 
You may also be able to create and SQL Expression as part of the Selection formula.
 
If you post a sample of  your data queries for the main report and subreport someone will likely be able to help with more specific suggestions.
 

Regards,
 
John W.
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 09 Aug 2007 at 11:24am
Ok, I haven't tried doing this either, but an idea is to implement a 'manual selection formula'. Use a global variable in the subreport to calculate the counts and put it in the report header (or group header). Then for the Detail section, put the 'manual selection formula' in the Suppress property. This way you can use the value from the subreport to suppress any records which don't meet that proper criteria. Again, I've never done this before but it sounds like it will work.
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
foxy
Groupie
Groupie
Avatar

Joined: 12 Jul 2007
Online Status: Offline
Posts: 50
Quote foxy Replybullet Posted: 10 Aug 2007 at 12:11am
Yea I tried this approach with the global variables or 'shared numbervar' is actually what i used. but i found that back in the main report I had to reset the global variable in the group footer or it just kept counting up. This seemed to cause all sorts of problems!
 
So i decided to get rid of the subreport completely and create a command table with some embedded SQL as follows.
 
select  ActionPlanId
FROM ActionPlan_GT A
WHERE EXISTS
( Select id From CPLan_GT_Level3 B WHERE A.CPLANGT_Level3ID = B.ID
AND
B.GT_Level3 = '6.9.1/ Benefit Critical' )
 
Seems like a much easier way of doing things!Big%20smile
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.016 seconds.