Solved

Crystal Subreports with Variable fields

Posted on 2013-12-10
1
414 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
1 Comment
 
LVL 34

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

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…
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 …
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

747 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now