Jump to content
We've recently updated our Privacy Statement, available here ×

Insert correctly number page in subreport?


tommaso81
Go to solution Solved by Gaizka,

Recommended Posts

I use to number the pages in the report the variable $V{PAGE_NUMBER}. This is correct in report, but in subreport with $V{PAGE_NUMBER} the pages start again from 1. How do I switch the pages properly, and continue numbering in the subreport correctly?

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

  • Solution

Hi,

you will need to pass as a parameter to the subreport the actual $V{PAGE_NUMBER} and sum it in the subreport.

You can do this by:

- Selecting the subreport in the designer and select the properties dialog in the property sheet and pass as a parameter the $V{PAGE_NUMBER} param from report to subreport

- Translate page number param into a number, sum the original $V{PAGE_NUMBER} and then convert it back to string in order to display it.

 

Hope that helps

Link to comment
Share on other sites

Hi Gaizka, thanks for the reply. I have tried to solve the problem as you suggested.

- I created two parameters, one for the main report (num_pages_main, java.lang.Integer, default expression: $V{PAGE_NUMBER}) and one for the subreport (num_pages_sub, java.lang.Integer), subreport banner is locate in "summary" band of main report.

- By double clicking in the banner (subreport/subreport params menu) I tied num_pages_sub/num_pages_main ("params": num_pages_main and "expression": $P{num_pages_main} )

- I created a variable integer (var_pages_sub) in the subreport and I have the value of the parameter num_pages_sub.

Result: In subreport the variable (var_pages_sub) and the parameter num_pages_sub is null. In main report the parameter num_pages_main is rightly not null. The link between the parameters (main report/subreport) is correct because, for example, if imposed in the parameter num_pages_main the default expression: new Integer(1234), then in the subreport correctly 1234 as a result of num_pages_sub and var_pages_sub. Is very strange!

I could not even test the last point that you suggested because the parameter is null.

Link to comment
Share on other sites

Ciao Tommaso,

I think that the variable for page numbers is evaluated after you poass the parameter...

 

Why not try by adding the v_page_number string into the summary band or the page footer? In this way, the page number should be fine...I have several reports that use subreports and set the page number only on the first one..

 

Maybe it's the simplest solution... :-)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...