Solved

Crystal Report Shared Variable Value Lagging Behind SubReport Value

Posted on 2009-04-13
3
1,209 Views
Last Modified: 2012-05-06
I've created a Crystal Report to display the sum of labor hours taken from two separate, and disconnected data tables.  The report is meant to compare the total labor hours from each of the tables, and identify discrepancies.  The report information is grouped first by person, then by payroll date.  In a main report, I've created the person and payroll date groupings, and a column which displays the sum of labor hours from one of the mentioned tables in the payroll date group's footer.  In a second column, I've inserted a subreport which provides the labor hours summary from the second data table.  This report works fine, but I'd like to condition the color of the payroll date field to change when there are discrepancies between the two labor hour column values.

To provide for a conditional check, I've created a shared numeric value in both the main report, and the subreport.  In the subreport, I have a formula which sets the shared variable's value to that of the labor hours sum in the same group footer of the labor hours sum.  In the payroll date of the main report, I check the shared variable's value to that of the labor hours sum in the main report, to conditionally set the payroll date's font color.

The problem is that the shared variable's value seems to lag behind the actual labor hours sum returned by the subreport, and is present during the conditional check for the following record.  I've included a screenshot of the report's result.

Any help in understanding when the shared variable's value is being set would be much appreciated.
laborHedvsLaborDtl.jpg
0
Comment
Question by:C_Patrick
[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
  • 2
3 Comments
 
LVL 35

Accepted Solution

by:
James0628 earned 500 total points
ID: 24134365
The basic problem is that, at best, there is no way to guarantee that a subreport will be executed before a formula in the same section is evaluated.  AFAIK, it could go either way, but it's possible that the subreport will always be executed after the formulas are evaluated.

 Either way, the answer is the same - Execute the subreport in an earlier section of the main report, before you need the value from the shared variable.  If all that you're showing from that subreport is that total value, then simply create a new section above that one (eg. if the subreport is in a group footer, create another group footer section above that one), put the subreport in the new section and use the shared variable where the subreport was.

 Don't suppress the new section (with the subreport in it).  If you do, the subreport will not be executed.  Instead:
 Change the subreport so that it produces no output (eg. suppress all of the sections in the subreport).
 Go to the subreport format and on the Subreport tab, check the "suppress blank subreport" option.
 Go to the Section Expert for the section with the subreport in it and check the "suppress when blank" option.

 James
0
 

Author Closing Comment

by:C_Patrick
ID: 31569535
Your proposed solution works, James.

Thanks for your time in providing a detailed explaination of the problem, and its solution!

C. Patrick
0
 
LVL 35

Expert Comment

by:James0628
ID: 24147286
You're welcome.  Glad I could help.

 James
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

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…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
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…

615 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