rduncan10
20th March 2014, 19:11
I have a report that is normally printed two-sided. I have a request to change the report so that the main group always starts on a new page, so that each group can be separated.

I thought the code below might work, but it doesn't. The idea is to check when the group field changes, and check to see if the report is currently on the back of the page (the page # will be an even number). If it is, it should skip a page.


string old.maingroup.field(20)
before.maingroup.field.1:
before.layout:
if maingroup.field <> old.maingroup.field then
old.maingroup.field = maingroup.field
if(lattr.pageno \ 2) = 0 then
page()
endif
endif


One thing I noticed right away is that lattr.pageno actually shows the previous page number when the main.group changes. I tried changing the code to “if(latter.pageno + 1)\2) = 0 then”, but this didn’t work either.

I also tried adding this to the after.layout section, and adding two page() commands, but those didn't work either.

Thanks

bhushanchanda
21st March 2014, 09:26
Hi,

Are the domains same for both the fields i.e. maingroup.field and old.maingroup.field?

Have you checked under debugger if this condition satisfies?

if it doesn't then try:-

trim$(maingroup.field) <> trim$(old.maingroup.field)

Also make sure you have not added old.maingroup.field to report input fields as well.

rduncan10
21st March 2014, 17:24
Thanks. I can verify that the script is getting to the page() command in the second if...then statement. It is just not executing that command.