Author |
Message |
Gurbs
Senior Member
Joined: 16 Feb 2012
Location: Ireland
Online Status: Offline
Posts: 216
|
Topic: Pass date from sub to main report Posted: 29 Apr 2012 at 11:48pm |
Hi all,
I have a report that calculated the money we collected for each client. This is based on a date range. This is grouped by client code.
Then, in a subreport, I am calculating the commission we are getting for each client. I'm trying to get this information into the main report using a shared variable.
But now, when I want to show the commission, it shows a 0 for every client. While, when i just run the sub-report, I am getting results. Does this have anything to do with the order the report is set up? The subreport is in Detail, while the the rest of the information is in a group header.
Thanks in advance.
Kind regards,
Gerben
|
IP Logged |
|
yggdrasil
Senior Member
Joined: 19 Jun 2007
Location: United Kingdom
Online Status: Offline
Posts: 150
|
Posted: 30 Apr 2012 at 3:13am |
yes it does have to do with the way the report is set up. The shared variable you pass from the subreport in the Detail line cannot 'go back up' to the group header. It isn't calculated at that point. You will have to pass it down to the group footer, which may mean redesigning the way you display the report a bit.
|
IP Logged |
|
Gurbs
Senior Member
Joined: 16 Feb 2012
Location: Ireland
Online Status: Offline
Posts: 216
|
Posted: 30 Apr 2012 at 3:18am |
In the subreport it is in the group header as well... but It should work if I put it in the report footer? I'm going to try that today, thank you
|
IP Logged |
|
Gurbs
Senior Member
Joined: 16 Feb 2012
Location: Ireland
Online Status: Offline
Posts: 216
|
Posted: 30 Apr 2012 at 5:08am |
Even if the shared variable is in the report footer, it is only giving 0. While if I run only the subreport, I am getting values...
|
IP Logged |
|
yggdrasil
Senior Member
Joined: 19 Jun 2007
Location: United Kingdom
Online Status: Offline
Posts: 150
|
Posted: 01 May 2012 at 4:50am |
Are you resetting the shared variable for each client? Possibly you have the reset formula in the wrong place. This is hard to think what might be happening when I can't see your report,
|
IP Logged |
|
Gurbs
Senior Member
Joined: 16 Feb 2012
Location: Ireland
Online Status: Offline
Posts: 216
|
Posted: 01 May 2012 at 5:33am |
oke the way the report is set up now:
I have 2 groups, one on client code, and 1 on client name. I put both groups in Details section B. I then Suppressed them when duplicated, and suppress the detail section when it is blank.
In detail section A I have a subreport. In this subreport, I am calculating the commission we are getting per client. (Due to different date ranges I am forced to do this in a subreport). I linked this subreport on Start date and End date (2 parameters).
In the subreport, I have a formula that calculates the commission. This is in a group header, based on Client code. I then created the following formula:
shared numbervar OtherCosts;
OtherCosts := {@Other};
I placed this formula in the subreport.
In the main report, I created the following formula:
shared numbervar OtherCosts;
OtherCosts
I placed this one in the report as well. After this, I suppressed Detail section A (containing the subreport). But when I run the report now, I am always getting 0 for commission.
Does anyone sees what I am doing wrong here?
|
IP Logged |
|
DBlank
Moderator
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
|
Posted: 01 May 2012 at 5:37am |
you cannot suppress the subreport. It has to run in order to get the value.
there is a trick for this but unsupress it first just to make sure that is the problem.
Edited by DBlank - 01 May 2012 at 5:38am
|
IP Logged |
|
Gurbs
Senior Member
Joined: 16 Feb 2012
Location: Ireland
Online Status: Offline
Posts: 216
|
Posted: 01 May 2012 at 5:58am |
When I didn't suppress the detail section with the subreport, the report exploded. From 7 pages, there are not over 30K and counting. And it is picking up the wrong information aswell. He is not showing the commission amount on the right client...
|
IP Logged |
|
DBlank
Moderator
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
|
Posted: 01 May 2012 at 7:57am |
did you link the sub report to the main report (likely on client ID)?
basically the sub report will run once per instance that the section it is on in the main report is run. YOu have it on the detail section so it will run for every detail row that is run in the main report.
If you only have one row per client in the main report then you are OK, you just have to get the links from the main reprt to the sub report sorted out.
If you have multiple rows per client in the main report you might want to group on client and run the sub report from the group header so it onl runs once per client.
|
IP Logged |
|
Gurbs
Senior Member
Joined: 16 Feb 2012
Location: Ireland
Online Status: Offline
Posts: 216
|
Posted: 02 May 2012 at 2:25am |
ok an update an this:
1. I've changed the linking, the subreport is now linked on start date, end date and client code.
2. I put the subreport in group header 1, and the rest of the report in group footer 1.
Now, it is starting to look like it's going in the right direction. But, not for every client there is a commission. Now, when there isn't a commission, where it should say 0, it is picking up the amount from the previous client.
Also, if possible, I would like to get rid of the extra spaces in between the different clients (I minimized the fields in the subreport as much as possible, and did the same for the group header)
|
IP Logged |
|
|