Use Global!.TotalPages Parameter to be sent to stored procedure after report rendering

92 Views Asked by At

I'm trying to update a record in database using the built-in parameter Global.TotalPages of a report but I just can't do it.

I've tried to use a sub-report in which I call a stored procedure to update said record, but I can't send the Total Pages variable as a param since I can only use the Global.TotalPages in the header.

I've also tried to call the sub-report on header but that's something that can't be done.

Does anyone have any ideas on how can I use the Global.TotalPages value to update a record in the database?

PS: I've also tried to calculate the number of pages using the formula:

(TotalRowsINResultSet / RowsPerPage) 

but it's not always exact, sometimes I get 1 less page, other times 1 more page, and other times I get the correct number of pages.

1

There are 1 best solutions below

4
On

I think that the issue is that TotalPages is only calculated after the body of the report is rendered, so it will not be available for other calculations...

However, you should be able to use you simple Expression to calculate the number of pages if you modify it.

Try using

CEILING(TotalRowsINResultSet / RowsPerPage)

This will ensure that the result of the division is rounded up to the nearest whole number. Your original expression might have calculated this incorrectly. For exmaple, if the total rows was 12 and rows per page was 10, then the result would be 1.2 which, depending on how you tried to get the integer part, might give you a result of 1 rather than 2.