| Author |
Message |
jennifer_falcon
Newbie
Joined: 15 Jan 2009
Online Status: Offline
Posts: 35
|

Topic: How do I get my shared variable to work? Posted: 23 Mar 2010 at 12:36pm |
|
Hello!
I have a report that looks like this:
Group Header: amAsset.AssetTag
Details Section:
Assettag Platform Nature Expense subreport1
The subreport has Description, dStart and dEnd
Therefore the details look like:
AssetTag Platform Nature Expense Description dStart dEnd
When I go to export the information to Excel (Data Only), the subreport information (Description, dStart and dEnd) appear on the second line of the report. It does not appear with the rest of the data (AssetTag, Platform, Nature)
I had read in other posts that you can pass the information from the subreport to the Main report by using shared variables.
In the subreport, I have created formulas to display the shared variable information:
For Description the formula I have is:
whileprintingrecords; Shared Stringvar desc:= {amCntrRent.Description}
For dStart, the formula I have is:
whileprintingrecords; shared DateVar dstart := {amContract.dStart};
For dEnd, the formula I have is:
whileprintingrecords; shared DateVar dend := {amContract.dEnd};
In the Main Report I created a formula called desc. With this formula, I want to take the results of the shared variable desc from the subreport, and I want to put it into the Main Report.
When I do this, I am getting weird results.
AssetTag Platform Nature Expense Description BE00001 MFR IBM $100 This is blank and it shouldn't be BE00001 MFR IBM $200 L-0505 BE00001 MFR IBM $300 L-0505
The first line of my Assets is always blank even though the description should be L-0505.
Each asset belongs to one Description.
I can't figure out why the report is leaving the first instance of the Description blank.
When I leave the subreport with the actual field names, I get data for each line. It is as soon as I use shared variables that I run into this issue.
Description is a stringvar, dStart and dEnd are datevars.
How do I make it so my report shows the data in the first lines of my details section?
|
IP Logged |
|
|
|
lockwelle
Moderator
Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
|

Posted: 24 Mar 2010 at 3:15am |
what is probably happening is that the subreport is being called after the shared variable is being accessed. What I would try is to create a new detail section above the existing detail. Move the subreport into it and suppress the section (or make it really small...I can never remember which will work). This will call the subreport before the shared variable is to be printed and everything should work as expected.
HTH
|
IP Logged |
|
jennifer_falcon
Newbie
Joined: 15 Jan 2009
Online Status: Offline
Posts: 35
|

Posted: 24 Mar 2010 at 10:41am |
|
Hi there!
I am very happy to say that your solution is working 99% for me.
I moved the subreport to Details A. I move the rest of the fields to Details B. I made the subreport very tiny but not hidden. When I hide it, the report doesn't work at all.
The report works for the most part except for when the subreport fields are blank.
If the subreport fields are blank, the main report details get filled in with the data from the record that last contained data in the subreport.
The report looks like this
Group #1 AssetTag: BE00001 Da (contains the subreport) L-0505 Db AssetTag Platform Nature Expense Description BE00001
MFR IBM $100 L-0505 BE00001 MFR IBM $200 L-0505 BE00001
MFR IBM $300 L-0505
Group #1 AssetTag: BE00002 Da (contains the subreport) L-0101 Db AssetTag Platform Nature Expense Description
BE00002
MFR IBM $100 L-0101
BE00002 MFR IBM $200 L-0101
BE00002
MFR IBM $300 L-0101
Group #1 AssetTag: BE00003
Da (contains the subreport) Subreport is blank
Db AssetTag Platform Nature Expense Description
BE00003
MFR IBM $100 L-0101
BE00003 MFR IBM $200 L-0101
BE00003
MFR IBM $300 L-0101
The BE00003 AssetTag has a blank subreport, but it prints the Description from the last AssetTag: BE00002
BE00004 has a blank subreport and it prints the Description from AssetTag BE00002
Is this an issue with resetting the variable? Or, how do I put in my Description formula that if the subreport is blank, don't print off any information?
Thanks!
|
IP Logged |
|
Yudi
Newbie
Joined: 03 Aug 2009
Online Status: Offline
Posts: 13
|

Posted: 24 Mar 2010 at 10:59am |
Hi jennifer
I think you don't need to create shared var on your subreport and obtain it's value from main report. I think what you need is to pass the parameter from main report to subreport, and filter the record on subreport based on the given parameter value
For your situation, you just need to create main report with a detail section (not two) and place your subreport on it. Then you need to pass the AssetTag value to subreport so the subreport will display the corresponding "Description" for the given "AssetTag"
Edited by Yudi - 24 Mar 2010 at 11:09am
|
|
|
IP Logged |
|
jennifer_falcon
Newbie
Joined: 15 Jan 2009
Online Status: Offline
Posts: 35
|

Posted: 24 Mar 2010 at 11:32am |
|
Hi Yudi,
When I place my subreport on the same details line as my main report details, I cannot get the data to export properly into Excel. The main report data exports to one line and the subreport exports to the line below it. It was suggested in other forum articles to use shared variables in a formula. That way, you can add the formula lines to the same details line as the main report data. When I do that, the information exports correctly to Excel. If it wasn't for the bad exporting, I would leave the subreport in the same details line.
|
IP Logged |
|
Yudi
Newbie
Joined: 03 Aug 2009
Online Status: Offline
Posts: 13
|

Posted: 24 Mar 2010 at 12:51pm |
Hi, Jennifer
i'm sorry. i'm less rigorous that your concern is issue when exporting data to excel.
it's worked well both printing and exporting on my PC. hope it useful.
|
|
|
IP Logged |
|
lockwelle
Moderator
Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
|

Posted: 25 Mar 2010 at 3:20am |
You could create one more shared variable...I hope that this works, I don't use subreports too often and I never bind to the db...anymore.
Have the subreport return a count of the records, and if it is 0, then you can modify the printing of the items.
It is at least worth a try.
HTH
|
IP Logged |
|
zuidermark
Newbie
Joined: 21 Apr 2010
Location: Netherlands
Online Status: Offline
Posts: 2
|

Posted: 21 Apr 2010 at 1:08am |
Originally posted by jennifer_falcon
Hi Yudi,
When I place my subreport on the same details line as my main report details, I cannot get the data to export properly into Excel. The main report data exports to one line and the subreport exports to the line below it. It was suggested in other forum articles to use shared variables in a formula. That way, you can add the formula lines to the same details line as the main report data. When I do that, the information exports correctly to Excel. If it wasn't for the bad exporting, I would leave the subreport in the same details line.
Hi Jennifer, about the exporting problem to Excel with a subreport did you solve that in the meantime? I am experiencing the same problem.
|
IP Logged |
|
|
|