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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subreport Variable 1

Status
Not open for further replies.

bdjb

Technical User
Oct 29, 2002
292
US
Hello,
I'm using CR 11, I have a subreport that works fine, I added a formula to the subreport to create a shared date variable to pass to the main report, the main report gets the data, but it is one "line" below the other data. I have the subreport and main data on the detail line.

Example

Main Shared Variable

1/10/10
1/11/10 1/10/10
1/12/10 1/11/10
1/12/10

Thanks in advance!
 
Move the subreport to a detail_a section with other fields in detail_b. Shared variables can only be referenced in sections following the one containing the subreport. But why share it at all? You could just suppress everything but the datefield and display the results directly.

If the situation is more complex, you can share the variable and then reference it in detail_b and make detail_a disappear by:

1-suppressing all sections within the subreport.
2-formatting the subreport (format->subreport->subreport tab->check "suppress blank subreport"
3-remove the borders from the subreport
4-in the main report->section expert->detail_a->check "suppress blank section."

What you CANNOT do (and still share the variable) is to suppress the subreport itself or the detail_a section.

-LB
 
Thank you! I have to share the data because I need to do a calculation using it. They are two dates and I have to find the difference.

 
The variable works fine (almost). I get the data on the correct line now, but when there is a blank, it duplicated the last date. How can I get it to stop that?

Subreport Variable
12-1-10 12-1-10
12-2-10 12-2-10
12-2-10
12-4-10 12-4-10
 
You need a reset formula for the shared variable:

whileprintingrecords;
shared datevar yourvarname := date(0,0,0);

Place this in a suppressed detail_c section.

-LB
 
Thank again! That fixed it. You are always quite helpful! Now I can add this new knowledge to 26 more reports :')

I know I can't directly use the result of the date difference in the main report's select expert to only pull >21 days, is there any way to do it with another shared variable or something?

Thanks again!
 
You will have to use a section suppression formula like this:

whileprintingrecords;
shared datevar yourvarname;
datediff("d",yourvarname,{table.date}) > 21

Make sure the more recent date in the third condition. Or if you want to suppress differences in either direction, change it to:

abs(datediff("d",yourvarname,{table.date})) > 21

-LB
 
That worked great, I'd send you a glass of your favorite beverage if I could!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top