Solved

Crystal Report Shared Variable bring 0s

Posted on 2011-09-15
8
326 Views
Last Modified: 2012-05-12
I have a sub reports named sub_1. I got the sum value and created an shared variable [sum], and try to bring back to the main report and put in the detail section.

Sub_report->[Share_Variable_ Prior_Lease_Year_Sales]
shared NumberVar Prior_Lease_Year_Sales={sum}

Mian report->[Share_Variable_ Prior_Lease_Year_Sales]
WhilePrintingRecords;
shared NumberVar Prior_Lease_Year_Sales;
Prior_Lease_Year_Sales;

I put the shared variable in the detial section of main report  and link them by [sale_id]
1. I found out the first value of share variable always gives 0. which the actual value is not 0. and also realize that the correct value always offset one row.
2. Also, If the there is no value return from the subreport shared variable, then in the main report, that record willl read the previous's share variable's value. I want to see 0 if there is no value return.

How can I fix issue 1 and 2.

Thanks in advance!
0
Comment
Question by:FinghtingMiao
[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
  • 6
8 Comments
 

Author Comment

by:FinghtingMiao
ID: 36546370
I already figure out the issue 2 just use reset to 0 for each record.
But is anyone can help me on issue1?
Thank you a lot.
0
 
LVL 101

Accepted Solution

by:
mlmcc earned 500 total points
ID: 36546591
The subreport has to be in a section before the main report usage.

Where is the main report formula?

You may have to add extra sections
Right click the detail section in the left margin
Click INSERT SECTION BELOW
There is no a details A and B
Details A can have the subreport while details B can have the main report formula.

All main report formulas are evaluated before a subreport is evaluated in the section.

mlmcc
0
 

Author Comment

by:FinghtingMiao
ID: 36550206
mlmcc:
The solotion u provided works! But the @reset does not work any more.
@reset
whileprintingrecords;
NumberVar Prior_Lease_Year_Sales:=0;

I put  it in the main report, and no matter where I put it, the Prior_Lease_Year_Sales sitll display last record(sale id)'s value if the subreport return no data. But what I am lookin for is: If subreport bring no data for this record, the Prior_Lease_Year_Sales should display 0.

Thanks again!
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:FinghtingMiao
ID: 36550230
SOrry, I got the answer! I just miss-spell the variable name.

Thank you!
0
 

Author Comment

by:FinghtingMiao
ID: 36550725
I've requested that this question be closed as follows:

Accepted answer: 0 points for FinghtingMiao's comment http:/Q_27311024.html#36550230
Assisted answer: 500 points for mlmcc's comment http:/Q_27311024.html#36546591

for the following reason:

thank you. It is a good tip I should keep in mind if use shared variable in crystal report
0
 

Author Comment

by:FinghtingMiao
ID: 36550726
Miss type
0
 

Author Closing Comment

by:FinghtingMiao
ID: 36550730
thank you. It is a good tip I should keep in mind if use shared variable in crystal report
0
 
LVL 35

Expert Comment

by:James0628
ID: 36553754
 > I just miss-spell the variable name.

 You have to be very careful about that.  CR doesn't try to do any cross-checking or anything like that.  If you mis-type a variable name, you just create a new variable.  I will often copy variable declarations from one formula and paste them into other formulas, to make sure I get the names correct (and just to save some typing :-).

 You also need to be careful about the variable types - Local, Global and Shared.  They're all separate.  If you declare a Shared variable in one formula and a Local variable with the same name in another formula, those are two separate variables.  You have to make sure that the names and types are consistent.

 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

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 Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

690 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