Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CRW 9 Subreport returns wrong 0.00 Currency value 1

Status
Not open for further replies.

sultan123

Technical User
Nov 11, 2003
28
GB
Thank you in advance..

In subreport:
===========
WhilePrintingRecords;
Shared currencyVar RegSupSubTotal := sum({@RegSupRsale}, {COMPANY.STATE});

RegSupSubTotal;
(placed in GF of subreport)

In Main report:
==============
WhilePrintingRecords;
Shared currencyVar RegSupSubTotal;
RegSupSubTotal;

(subreport place in GF1a and
RegSupSubTotal placed beneath it in GF1b section of the main report)

In the subreport the shard var RegSupSubTotal gives correct value for that group...
BUT it displays 0.00 value for all groups!.


Please help if you can see what i am doing wrong?

many thanks.





 
Are you trying to use RegSupSubTotal as a running total or simply pass it back into the report to be used in Group Footer 1B? If so, you are resetting the value each time the subreport runs. If you want it to be a running total, your formula would need to be:

Shared currencyVar RegSupSubTotal := RegSupSubTotal + sum({@RegSupRsale}, {COMPANY.STATE});
 
Thank You FVtrainer

Ok I know tried what you suggested still the WRONG result.

Please note in subreport i am not using another variable but this instead sum({COMPANY.LASTYRSALE},{COMPANY.STATE});




Subreport
WhilePrintingRecords;
Shared currencyVar RegSupSubTotal := RegSupSubTotal + sum({COMPANY.LASTYRSALE},{COMPANY.STATE});
RegSupSubTotal;

RegSupSubTotal;
(placed in GF of subreport)

In Main report:
==============
WhilePrintingRecords;
Shared currencyVar RegSupSubTotal;
RegSupSubTotal;

(subreport place in GF1a and
RegSupSubTotal placed beneath it in GF1b section of the main report)

I have tried many things still very stuck any more help would be very appreciated..


thanks
 
Ok, let's go through this from the beginning. I'll probably give you a getter answer this way. First I'll ask a couple of questions to clarify some things.

In group footer 1a you have the subreport. In that subreport you have a formula (this is the first formula you listed):

WhilePrintingRecords;
Shared currencyVar RegSupSubTotal := sum({@RegSupRsale}, {COMPANY.STATE});


Question 1: Does this formula print on the subreport (i.e., is it visible)?

Question 2: Is this formula producing the result you want within the subreport?

Now, in the main report, you have listed the following formula:


WhilePrintingRecords;
Shared currencyVar RegSupSubTotal;
RegSupSubTotal;

Question 3: What result do you want to appear in this formula as each instance of group 1 is printed? For example, if the subreport in the first instance of Group 1 shows a value in the subreport formula of $100 what should the formula in group footer 1b of the main report show? $100? Then, if in the next instance of Group Footer 1, the subreport formula shows a value of $50, what should the formula in group footer 1b of the main report show? $50 or $150?






 
Thanks for your time first,
Okay here we are then


Sorry for the capital letters below just to make answer stand out.

Question 1: Does this formula print on the subreport (i.e., is it visible)?

YES

Question 2: Is this formula producing the result you want within the subreport?

YES
Now, in the main report, you have listed the following formula:



Question 3: What result do you want to appear in this formula as each instance of group 1 is printed?

For example, if the subreport in the first instance of Group 1 shows a value in the subreport formula of $100 what should the formula in group footer 1b of the main report show? $100?

SINCE MAIN AND SUPREPORT ARE GROUPED AND LINKED VIA REGION:THUS
100


Then, if in the next instance of Group Footer 1, the subreport formula shows a value of $50, what should the formula in group footer 1b of the main report show? $50 or $150?

50
AS I ONLY WANT TO TOTAL VALUE RELATED TO THAT GROUP ONLY


Thank you again

 
I am not sure if this would make any difference but the fields in report are from .dbf where as the main report uses maaccess .mdb
 
Well, I don't think the db source makes a difference. I also don't see anything in your original formulas themseleves that should be causing a problem. However, you are placing the subreport's shared variable formula in the group footer. Is there a reason why it can't go in the report footer? Or, another way of looking at this is for you to place the following formula in the subreport's report footer to see what it displays:

WhilePrintingRecords;
Shared currencyVar RegSupSubTotal;

If this formula is placed in the subreport's report footer, does it show the correct amount or does it show 0.00?
 
No that does not work either


I am really frustated. I even deleted all the fromulae and recreated them still no luck.

Anyone with any clues PLEASE!
 
You know, saying "No that doesn't work either" doesn't answer my question very well. You didn't tell me whether the above formula, placed in the report footer, showed a value or whether it showed 0.00. What is the result when you place the above formula in the subreport report footer? Does it show $0.00 or does it show the same value as your formula does the subreport group footer?
 
Hi

WhilePrintingRecords;
Shared currencyVar RegSupSubTotal;

NO, it retruns the correct values

further:

However placed in the subreport rpt in a higher position does return 0.00, same incorrect values as it does in the main report.


This means that the @formula field containing the above variable shown below:

Shared currencyVar RegSupSubTotal;
RegSupSubTotal := sum({COMPANY.LASTYRSALE},{COMPANY.STATE});
RegSupSubTotal;

So it MUST be PLACED on the subrpt BEFORE the the referencing formula.

Which is what i am doing.

I am not sure if this makes it a bit more clear??

thank you again
 
I ususally don't do this, but can you save the report with data and email it to me? You can send it to sgreen@itsconline.com.
 
Ok, so in the sample report you sent me, you have a formula {@SupSubT} in the subreport as follows:

Shared currencyVar RegSupSubTotal;
RegSupSubTotal := sum({COMPANY.LASTYRSALE},{COMPANY.STATE});
RegSupSubTotal;

This is different from the first post, where you had the "WhilePrintingRecords;" statement at the top of the formula. Please re-insert this statement in the formula so it reads:

WhilePrintingRecords;
Shared currencyVar RegSupSubTotal;
RegSupSubTotal := sum({COMPANY.LASTYRSALE},{COMPANY.STATE});
RegSupSubTotal;

Also, in the main report you have the formula {@pullingSharedVar} as:

Shared currencyVar RegSupSubTotal;

Again, this is different than in the first post. If this is how this formula has always been, then it is understandable that you've been getting $0.00 as a result. Without the "WhilePrintingRecords;" statement in the formula, Crystal will evaluate this formula (and every occurance of the formula in the report) before the subreports are printed. Your {@pullingSharedVar} formula must read:

WhilePrintingRecords;
Shared currencyVar RegSupSubTotal;

I've made the changes to the report you sent me and emailed it back. I've also changed the other formulas that reference variables to use the WhilePrintingRecords statement.

If this does not solve your problem, please do the following:

1) Run the report and preview it.
2) With the preview window open and showing the incorrect results, go to the File menu and select the "Save Data with Report Option". Then choose File | Save.
3) Send the report to me again and I'll have another look.
 
Still no luck. I have mailed it back to you as you have asked above ie with the saved data.

Thank you.
 
Ok, now I get it. Your subreports are "on-demand" subreports. They don't generate until the user requests them. So the main report runs, but the subreports don't run until someone asks for them (i.e., clicks on the subreport link). So there is no data in the subreport to populate the shared variable when the main report is running. In short, shared variables don't work with on-demand subreports.

If the subreport needs to remain "on-demand", then you will need to actually put the subreport in twice. I modified the report you sent to include the new section you'll need. Your report currently has a gf 1a and gf 1b section, with the subreport in 1a and the formula to display the shared variable in 1b. I've modified the report so that there are now 3 sections in your group footer. The 1b section will now used for a 2nd copy of the subreport which is not created as an on-demand subreport. However, all sections in this subreport will need to be suppressed so the data doesn't show up on the main report. The 1b section itself is set to underlay following sections, so 1c will print on top of it.

I couldn't test it out because I don't have access to your database, but it should work if you create the subreport a 2nd time as described above.

Also, in the on-demand subreport, you should remove the formula the updates the shared variable.
 
FVTrainer

Excellent it works!


Its nice to find people, like you, who go a distance to help others.

Many thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top