Solved

How would I share a subreport column value with another subreport on the main report?

Posted on 2013-01-10
15
471 Views
Last Modified: 2013-03-14
I would like to share an integer column from a subreport with another subreport on the main report.  Is this possible in Crystal 10?
0
Comment
Question by:JeffDun
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 7
15 Comments
 
LVL 77

Expert Comment

by:peter57r
ID: 38763750
I think we need a bit more explanation of what you are trying to do.
You can add any column from the data source to a report.  If it's not in the data source then you may be able to use a formula field to create the required value.

Subreports and especially their placement might add further considerations to the process.

But we need more detail.
0
 
LVL 100

Accepted Solution

by:
mlmcc earned 500 total points
ID: 38764190
WHen you say column are you meaning all the records in the column?

Basic idea is

Main report
    Subreport 1   in its own section
    Subreport 2 in a later section

In the main report you declare the SHARED variables.  I generally do it in the main report header.

WhilePrintingRecords;
Shared NumberVar TotalSub1;
""

In Sub1 you add a formula to set the value
WhilePrintingRecords;
Shared NumberVar TotalSub1;
TotalSub1 := Sum({Somefield});
""

In Sub2 you can display hte value or use it
WhilePrintingRecords;
Shared NumberVar TotalSub1;
TotalSub1 + Sum({FieldInSub})

mlmcc
0
 

Author Comment

by:JeffDun
ID: 38765007
Sorry, I was referring to one of the fields in my subreport.

Here is what I have:

Main Report
     Subreport 1   in its own section
     Subreport 2   in its own section

I have a field that is being dispalyed in the Subreport 1 that is needed to populate Subreport 2.  Initially, I tried to add Subreport 2 to Subreport 1 but I noticed that functionality was not supported.  So, I added Subreport 2 in its own section on the main report.  I just need to pass the field value from Subreport 1 as the input parameter to Subreport 2.
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 100

Expert Comment

by:mlmcc
ID: 38765489
The method I outlined above will work

mlmcc
0
 

Author Comment

by:JeffDun
ID: 38767324
I tried using the formulas below in the Main and Subreport but shared value is not being returned on the Main report.  

Main Report
WhilePrintingRecords;
Shared NumberVar EmpID;
""


Subreport
WhilePrintingRecords;
Shared NumberVar EmpID := {usp_Get_Emp_Rpt;1.Emp_ID};

I placed the shared variable on the main report detail section to see if any value was being returned and nothing was displayed.

Not sure if it makes a difference but subreport1 is in report footer b.  The shared value from subreport 1 is needed in subreport 2 which is in report footer c.  I tried the formula in report footer c and the report header.
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 38768134
What formula did you use in the report footer c?
It should be something like
WhilePrintingRecords;
Shared NumberVar EmpID;
EmpID


mlmcc
0
 

Author Comment

by:JeffDun
ID: 38768339
I tried the two below.

WhilePrintingRecords;
Shared NumberVar EmpID;
EmpID := EmpID;


WhilePrintingRecords;
Shared NumberVar EmpID;
EmpID

0.00 is being displayed in report footer c.  The formulas are in formula fields, is that correct?
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 38769247
Does the subreport display anything?

mlmcc
0
 

Author Comment

by:JeffDun
ID: 38770980
Yes, the subreport and the main report now display the correct value.  However, the value inside is being displayed with two decimal places(45.00).  The second subreport on the main report is expecting 45 with no decimal places and is still not being displayed.

Also, is there a way to set the subreport parameter equal to the shared variable value?  I right clicked the subreport and clicked "Change subreport links" to set the parameter equal to the shared variable.  When I edit the subreport, I noticed that there are now two parameters.  The parameter that stored procedure is expecting and the shared variable I manually linked.  Is there anyway to remove the stored procedure parameter or set the stored procedure parameter equal to the shared variable value?
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 38771174
WHen you set the link to the subreport you may be able to link to the stored procedure parameter.  Choose it from the list rather than using the one it suggests (?pm-value)

45.00 and 45 are the same unless you are passing it in as a string.

How did you use the shared variable in the second subreport?

mlmcc
0
 

Author Comment

by:JeffDun
ID: 38772835
I clicked Change subreport links, used the main report formula for "fields to link to", and used the stored procedure paramater name for "Subreport parameter field to use".  Nothing is being displayed in the report on the main page.  I don't think the formula value is being passed correctly.
I can get the formula value to display in report footer c but its not being passed as a parameter to the subreport
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 38773087
Are you trying to pass the shared variable to the subreport as a parameter?

I don't think you can do that.

mlmcc
0
 

Author Comment

by:JeffDun
ID: 38773159
yes.  Is there another way to do this? The first subreport returns an ID that i need to use in the second subreport.
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 38773185
When you say use, does that mean as a parameter to the subreport stored procedure?

What type is the parameter?

mlmcc
0
 

Author Comment

by:JeffDun
ID: 38773210
Yes, the shared variable is a parameter to the subreport stored procedure.

The type is integer.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question