cancel
Showing results for 
Search instead for 
Did you mean: 

Passing a variable from subreport to the main report

Former Member
0 Kudos

Hi guys, was unable to google this, so Im urning to you guys:

I was wondering whether it was possible to do this:

I have a subreport taking data from a table. In the main report, in the suppres condition of details section containing this subreport, I need to have a variable containing the total count of rows in that table. I know there are shared variables for that, but the problem is, that the variable in the condition is processed sooner than the one in the subreport.

Any ideas on this?

Thanks a lot

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Do you want to Suppress the details section if there are no records in subreport by passing the count from subreport to mainreport?

To get the count from subreport to main report try creating formula like this in subreport

shared numbervar i:=count(field);

in the main report create a formula like

shared numbervar i;

this sould be processed only after your subreport to work

Regards,

Raghavendra

Former Member
0 Kudos

To Sharma:

Hi, unfortunately I can't. The subreport has its specific position in constallation with previous and following sections and must be right there.

To Raghavendra:

Hi, that was my first idea, but the problem is as I explained in my first message.

To both:

I have a table in subreport. This subreport is in main report positioned in details section "x". and I want to use that shared variable in the suppress condition of section "x". The problem is that the formula in suppress condition is processed sooner than the formula assigning a value to the shared numbervar inside the subreport.

and thats what im looking for - a workaround for that. btw im using CR 8.5

thanks again guys

Former Member
0 Kudos

If there are no links between main report and subreport I would suggest to add new command in main report like

select count(field) from subreport table

and don't link this field with main report tables.

Now you can use this field (count) any where in the report and suppress accordingly.

Regards,

Raghavendra

Former Member
0 Kudos

thats what I did first (using SQL query), but, this thread:

explains, why is it difficult to use SQL queries in CR 8.5 and anyways theres also another problem regarding changing ODBC source servers, which makes it even more complicated and sofar undoable. so sofar Im not able to use SQL queries. thats why i was wondering whether it could be done by shared variables.

Former Member
0 Kudos

If so I think we have to process the subreport once before printing the subreport on main report. Better to create a new subreport that doesn't contain any fields in design and create a formula as I told for shared variable and try to place this in header section (remember we are creating this report just to get the count from sub report to main report) and compress the subreport as small as possible and then use that shared variable in suppress condition.

There may be a better solution but I think this would help you.

Raghavendra

Former Member
0 Kudos

OMG how come that idea didnt cross my mind at all!

its not very systematic though, but using a new subreport just to find out that count totally solves my problem..

Thank you!

Answers (1)

Answers (1)

Former Member
0 Kudos

Can you not insert the sub-report in section other than main report details section such as report header, or page header and suppress it?