Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: Question on shared variables Post Reply Post New Topic
Page  of 3 Next >>
Author Message
Nav522
Senior Member
Senior Member


Joined: 25 Aug 2009
Location: United States
Online Status: Offline
Posts: 166
Quote Nav522 Replybullet Topic: Question on shared variables
    Posted: 31 Jan 2011 at 7:45am
Hello Folks,
                   Am having trouble in pulling the shared variables from the subreport to the main report and suppress the main report records based on the shared variable.
I have the main report with Report Header suppressed,Page Header Suppressed.Detail section shows field called code.
 
 Report Footera has the subreport1
and ReportFooterb has the subreport2
 
Subreport1 has everything suppressed except details. And i have the shared variable placed in the reportheader suppressed and it is
@shared1 is
whileprintingrecords;
Shared Stringvar subroline;
subroline := {@Substring2};
 
 
 
subreport2 has the same thing but i have different variable name
@shared2 is
whileprintingrecords;
Shared Stringvar subro;
subro := {@Substring2};
 
So finally am bringing in the two shared variables into the main report
as
@sharedmain1 is
whileprintingrecords;
Shared Stringvar subroline;
 
@sharedmain2 is
whileprintingrecords;
Shared Stringvar subro;
 
and i have placed them in the main report page header and suppressed them
 
Ultimately Under suppress of
Detail section of the main report has the condition if @sharedmain1 = left(code,21) then True Else False.
 
But for somereason i still see the records that are supposed to be suppressed. I dont know wat am missing. Any help?
 
 

 




Edited by Nav522 - 31 Jan 2011 at 8:38am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 31 Jan 2011 at 7:52am
You stated that you have the Main report page header suppressed and that the sub report is placed int eh page header.
When you supress a sectiont hat a subreport resides on it does not run the sub report at all.
Also I assume this is a static result fromt her sub report so by placing it on a page header you are running it multiple times when it only needs to run once.
To get it tested move your shared varibals in the main report onto your detailsectino to see if you get the expected variable results
IP IP Logged
Nav522
Senior Member
Senior Member


Joined: 25 Aug 2009
Location: United States
Online Status: Offline
Posts: 166
Quote Nav522 Replybullet Posted: 31 Jan 2011 at 7:56am
Hi there Thanks for getting back.
No I have the shared variables placed in the main report page header
 i.e.
@sharedmain1
and @sharedmain2
 
 Subreports are placed in reportfooters.
 
And btw i tried to check what you had said. I tried to pull in the @sharedmain1  and @sharedmain2 into the detail section and they show blank. And also there is no linking to the subreports.
 


Edited by Nav522 - 31 Jan 2011 at 7:58am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 31 Jan 2011 at 8:00am

Let me make sure i understand.

You are trying to  suppress rows inthe main reprot based on values from the sub report using shared variables correct?
If the value is being generated from the sub report, the sub report has to reside in a section above the location that is is going to be used (e.g. report header). Then it can be passed to the main report in a section below it (report header B).
and then those values can be used in the sections below it (group headers, details or any footer).


Edited by DBlank - 31 Jan 2011 at 8:02am
IP IP Logged
Nav522
Senior Member
Senior Member


Joined: 25 Aug 2009
Location: United States
Online Status: Offline
Posts: 166
Quote Nav522 Replybullet Posted: 31 Jan 2011 at 8:07am

 

Yes thats correct.
----------------------------
Okay i tried to place the subreports in ReportHeader.
Now the shared variable is populating the data in the detail section but its duplicating.
 
and after investigating the duplicating record seems to be the 1st record of the subreport1.
 
I dont think its pulling in all the records correclt into the main report?


Edited by Nav522 - 31 Jan 2011 at 8:44am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 31 Jan 2011 at 9:28am
BY placing a subreport in a header it will always only return one value because it only runs once.
It soundsl like you are trying to supress detial rows in the main report that have mathcing rows in the sub reports.
Maybe if you start frm scratch on exoplining your data and what you need to do?
IP IP Logged
Nav522
Senior Member
Senior Member


Joined: 25 Aug 2009
Location: United States
Online Status: Offline
Posts: 166
Quote Nav522 Replybullet Posted: 31 Jan 2011 at 9:44am
Okay i will try to explain.
 
The report object "code" in the main report detail section has the data as following.
1TRAN053-0000134-2011C
1TRAN033-0000123-2011C
1TRAN023-0000123-2011C
 
The subreports report object has the data of kind
 
1TRAN053-0000134-2011Y
1TRAN033-0000123-2011Y
 
My requirement is if the subreport rows matches the main report rows then subreport has precedence over the main report data i.e. code with 'Y' stays on the report(Subreport Rows) and the code with 'C' is suppressed(Main report detail rows)
 
So in our case for example
 
1TRAN053-0000134-2011C
1TRAN033-0000123-2011C
should be suppressed in the main report because those two rows are present in the subreport with Y  only the change.
 
so thats the reason i have the formula in the main report detail section  under Suppress saying
 
@sharedmain1 = left(code,21) then True Else False.
 
Does it makes sense now?


Edited by Nav522 - 31 Jan 2011 at 9:46am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 31 Jan 2011 at 9:53am

What is the common element to know that

1TRAN053-0000134-2011C
is matching to
1TRAN053-0000134-2011Y
IP IP Logged
Nav522
Senior Member
Senior Member


Joined: 25 Aug 2009
Location: United States
Online Status: Offline
Posts: 166
Quote Nav522 Replybullet Posted: 31 Jan 2011 at 9:58am
Well i have created a formula for that as @substring
Left({Command.'1TRAN'||ECF.CLIENT_FIELD_DATA},21) in the main report.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 31 Jan 2011 at 10:00am
so these come from two different tables that you cannot join on hence the use of a subreport?

Edited by DBlank - 31 Jan 2011 at 10:12am
IP IP Logged
Page  of 3 Next >>
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.