Solved

Crystal Subreports with Variable fields

Posted on 2013-12-10
1
430 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 500 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

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

Suggested Solutions

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 …
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

752 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