Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Crystal Subreports with Variable fields

Posted on 2013-12-10
1
Medium Priority
?
433 Views
Last Modified: 2013-12-11
I have 2 reports that I need to connect and I know it will probably need a variable setup.  It has been a really long time since I've need to do it and I just a blank.

The main report pull the payroll check detail for a "specific check date".  The second report totals the YTD gross payroll for the employee at the time of the "specific check date" using sums from 01/01/13 to the check date.  

I need to connect (I guess by subreport) and have a shared variable that I can then put that YTD Gross Payroll on the line with the check.  The common field in the 2 reports is the employee ID number.  

Can someone help me get started with this?
0
Comment
Question by:nursecore
[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
1 Comment
 
LVL 35

Accepted Solution

by:
James0628 earned 2000 total points
ID: 39710977
FWIW, it might be more efficient if you could create a query (eg. in a stored procedure or a CR Command) that would calculate the YTD, and use that query as the datasource for the report, rather than create a subreport that's run for each employee/check.

 For the subreport, I would create a report that reads the YTD data and give it parameters for the emp ID and check date.  It would also presumably need to calculate the starting date (eg. 01/01/13) based on the check date.  Use the parameters, and the calculated starting date, in the record selection formula.

 Create a formula like the following and put it in the subreport header or footer:

Shared NumberVar YTD_gross;
YTD_gross := Sum ({gross pay field})

 That's the basic idea, although it may not be quite that simple if you don't just have a single "gross pay" field.

 Insert that report as a subreport, and link your emp ID field and the check date to the subreport parameters.

 You can suppress the fields/sections in the subreport, and then use the "Suppress blank subreport" option in the subreport format, so the subreport doesn't produce any output on the report.  If you just suppress the subreport, or the section that the subreport is in, then the subreport won't be run.

 In the main report, create a formula similar to the following and put it in the report header.

Shared NumberVar YTD_gross;
""

 The "" is simply so that the formula doesn't produce any visible output on the report.  You could also suppress the formula field, or the section.

 In a separate section _after_ the one that contains the subreport, you can use YTD_gross in a formula to get the value from the subreport.

 Depending on your data and report structure, you may need to reset YTD_gross to 0 somewhere (eg. in a group header for each employee).  Otherwise, if an employee doesn't have any "history" for the subreport to read, they could get the total from the previous employee.  Like I said, whether or not that could happen will depend on your data and report structure.  I just wanted to mention it.

 James
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

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. …
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

719 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