Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Crystal Subreports with Variable fields

Posted on 2013-12-10
1
Medium Priority
?
436 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 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

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 …
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

963 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