views:

43

answers:

2

Hello guys, I have a pretty complex report. I have managed to create it up till the 1st sub report. Now I have to summarize the 1st sub report's fields inside a 2nd subreport 'horizontally'.

1) How do I pass the fields from sub report 1 to sub report 2 (Name & totals) & list them horizontally/each year?

2) How do I get each summary to show in a way like (Client1, Year1...YearN). If I am inserting a section for the second sub report it shows the 2nd sub report right after (Client1,Year1). I set page after in section expert but its not in order I wanted :|

I want to show this section after (client1,Year1-------YearN)

Report is designed in a way like

Main Report
   ---- 
       Sub Report 1
          Group (Client 1 Year 1)
          --------------------------------
          Name  Amount   TotalAmount
          --------------------------------
          John  1,000     300,000,000
          End of Page 
          ----------------------------------
          (Client 1 Year 2)
          --------------------------------
          Name  Amount   TotalAmount
          --------------------------------
          John  5,000     400,000,000 
          End of Page 
          ----------------------------------

          Group (Client 2 Year 1)
          --------------------------------
          Name  Amount   TotalAmount
          --------------------------------
          Stevens  1,000     10,000,000
          End of Page 
          ----------------------------------
          (Client 2 Year 2)
          --------------------------------
          Name  Amount   TotalAmount
          --------------------------------
          Stevens  2,000     40,000 
          End of Page 
         ----------------------------------
       End Sub Report 1
  -----
       Sub Report 2
  ----------------------------------------------------------------
    Name      TotalAmount        TotalAmount .......   TotalAmount
  ----------------------------------------------------------------- 
    John     Year1(TotalAmount) Year2(TotalAmount).... YearnN(TotalAmount)
    Stevens  Year1(TotalAmount) Year2(TotalAmount).... YearnN(TotalAmount) 

 End Sub Report 2

A: 

How do I pass the fields from sub report 1 to sub report 2?

Use Global var. Define the var in the main report as global and update in the subreport1 and access them in subreport2.

Kangkan
How about using a shared var ? What is the difference between global and sharedvar ?
Popo
Hi I tried using global var but since my 2nd sub report is inside Main report's footer (as I want it to show after 1st sub report) but the global numbervar is only returning 1 value.Is it possible by an array ? Like I store (ClientName,TotalAmt,Year) in array and print that out somehow in the 2nd sub report ?
Popo
Where (in which section did you declare the variables? If you are using in a subreport inside the report footer of the main report, declare the variables in the report header section.
Kangkan
Hey it's not working I have placed the formula field in the sub report header. It just shows only 1 record instead of a list of records from the 1st sub report.In my first sub report I defined a formula field likeWhilePrintingRecords;shared numberVar netprem:= {@Gross Premium}-(({Command.GENCOMMPERCENT}/100)* {@Gross Premium})In 2nd sub report I access it by shared numbervar netprem:=netprem;Only 1 numeric value is shown.
Popo
You should declare the variables in the report header of the main report and not in the header of sub-report.
Kangkan
+1  A: 

If possible, I recommend moving the sub-report data out of the sub-report into the main report, and putting a cross-tab into the report footer.

Mark Bannister
I exactly did as you told, now the problem has arised that some formula fields from sub report are needed in the cross tab. How to fetch them ?I cant move my 1st sub report into the main report as it is master detail layout, also the crosstab would work on master query in master report.
Popo
Select the formula fields in the subreport by clicking on them, Ctrl-C to copy them, then select the main report and paste them - the formula fields should appear in the Field Explorer as well as the report body for the main report. (Delete them from the main body if you have pasted them somewhere you don't want them.) You may need to edit the formulas in the main report if you changed any field names when moving the subreport data into the main report.
Mark Bannister
Thanks Mark. I will try that and let you know in a while.
Popo
Hi Mark, I tried what you said. Now it throws a field not known error (because the formula field 'c=a+b' had 'a+b' being returned from the query inside the sub report which it is unable to find on main report's query. Any clue ?
Popo
@Popo, my original answer was to move the sub-report data out of the sub-report into the main report (if possible). If a and b are in the sub-report query, the answer is to move them into the main report query; if a and b are already in the main report query, but are now called aa and bb, the answer is either to amend the formula to be c=aa + bb, or to rename aa and bb back to a and b (whichever is easier).
Mark Bannister