on 02-13-2009 2:56 PM
I'm having difficulty with a report I'm trying to write... I need to pass a value from the sub report to the main report. I've read elsewhere in the forum about the solution being a shared variable, and I've tried to implement it but it comes up as zero in the main report. Here's what I have:
In the subreport I have a formula called PassedEstTotal which looks like this:
WhilePrintingRecords;
Shared CurrencyVar EstTotal := Sum ({@TotalEstTime});
In the main report I have a formula called EstLab which looks like this:
WhilePrintingRecords;
shared CurrencyVar EstTotal;
CurrencyVar i;
i:=i+EstTotal;
PassedEstTotal does hold a value - I put it in the subreport and it properly shows a value of $283.99. But EstLab in the main report shows zero. What am I doing wrong here?
Are you sure your formula @TotalEstTime returns a currency value? I just want to make sure you are returning the correct data type. Can you try NumberVar instead. Also, as Vinay was suggesting, make sure that the subreport is placed in a section / group above the formula EstLab in your main report.
I hope this helps,
Regards,
Zack H.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Okay... I've got it working now. I pulled down the sample in the library which showed how to do it and I was able to get it working right. I made two changes and it's cooking now:
1. I had the subreport and the destination field in the same report footer section. I inserted a new section in the footer and moved the destination there. (This is the one which I think made the big difference.)
2. I copied the existing code for passing the variable and it now works. PassedEstTotal now reads like this:
whileprintingrecords;
shared numbervar x;
x:=Sum ({@TotalEstTime});
x
and EstLab now looks like this:
whileprintingrecords;
shared numbervar x;
x
Subreports calculate last. Your main report will have already been processed by the time it gets to your subreport, so as far as the main report is concerned the variable value is zero.
I can't load a screen capture in here, but check the 'Report Processing Model' in your help menu.
I ran into something very similar a little while ago. I ended up getting around it by writing a SQL statement that got me the same result. I'm not sure how feasible that is for your situation.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I misread your post earlier,
In your main report, for your EstLab, try using this formula and see if you get a value:
WhilePrintingRecords;
shared CurrencyVar EstTotal;
EstTotal
Regards,
Zack H.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jon,
Make sure that the shared variable which you are calling in the main report should be in the below section of the sub report. If you want to pass the sub report to the main report in the same section then insert section below the sub report
Regards,
Vinay
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.