I have created a report in which I have grouping on a field. This report is based on a foxpro table which is in /home/girish/fpd26. I have placed a page number control using Page N of M. It is working fine but I need to set the pagecount() based on the grouped data. At this moment, it is showing something like Page 1 to 100, but I need Page 1 of 1, if grouped data in one page, and if it grows more than 1 then Page 1 of 3, Page 2 of 3, Page 3 of 3 and it should be reset on next grouped data.
Wonât work with the Report Builder. There will always be counted the whole pages of the document. Also you couldnât restart the counting. So you have to edit the document after it has been created by the Report Builder. Or you have to create many standalone reports for every value in your group.
Thanks for your reply. I think this is important requirement and development team should work on it. Is there any possibility to achieve the goal because my report generates around 500 pages and editing 500 pages is not that much easy. Kindly suggest some steps and/or macro etc.
You hope there is a
but for ReportBuilder it isnât. There has only added one function since the fist version of LO. Some bugfixes also - that is all. Will have a look if this could solved by a macro âŚ
Maybe printing one report for every group.
Should be nice to know why that itâs necessary. Are those page numbers pointed anywhere? I guess not, if they are produced in the report. And such amount of pages I suppose are not printed on paper. If in a PDF, the tools in pdfs readers should help enough for any kind of search.
Will have a look if this could solved by a macro âŚ
A ray of hope from your side. I am waiting for your code and how to implement it (complete steps). Thanks in advance.
There are around 4000 schools in our state and every month, we have to produce a report which contains around 500 pages every month for them. In this 500 page report there are roughly 200 schools so, some school report expands in 3 pages and if we gives something like Page 220 of 505, then it create confusion. So, it will be better if it have Page 1 of 3, Page 2 of 3 for that school.
Have had a look: It will be possible to change the table for the Group Header to set the number for the page to â1â, but I donât find a way to set counter for the whole pages also.
So it would like
Page 1, Page 2, Page 1, Page 2, Page 3 âŚ
Have read you are using this for schools. Donât you need separate document for each school?
Yes, it will also work. I donât need separate report because I generates PDF and then it sends by mail to our printing department.
Fast solution:
SUB GroupNewPage
DIM oTables AS OBJECT
DIM oTable AS OBJECT
DIM inT AS INTEGER
oReport = ThisComponent
oTables = oReport.getTextTables()
FOR inT = 0 TO oTables.count() - 1
oTable = oTables.getByIndex(inT)
IF Left$(oTable.name, 11) = "Gruppenkopf" THEN
oTable.PageNumberOffset = 1
ENDIF
NEXT inT
END SUB
Have a look at the name of the group header. In my German version it is named as âGruppenkopfâ in properties of the header in the report. This group should be set to pagebreak before
.
Copy the code in your own macros, not in database.
Change the name of table. Be sure to set the the length of the word also (IF Left$(oTable.name, 11) = "Gruppenkopf" THEN
)
Execute the report, start the macro.
Pagenumber will restart for every new group to 1.
If you start the report by macro from base, oReport will be the object you have startet. So the code could be added to the code for starting the report.
Thanks again for your help. But, I am not getting where and how the name of group is going to affect in this code please? My table name is âLETFILE.dbfâ which is a dbase table stored in /home/girish/fpd26. I have written the :
IF Left$(oTable.name, 7) = "LETFILE" THEN
Am I missing something at macro level, because this is my first base report so I am not aware how and when to run the macro with report before/after, so please elaborate complete steps.
Name of the group header you could find (and set) here:
If you execute the report you could see the name of the group header as name of the first table
So: Open the report for editing.
Click on the group.
See general properties.
Set the name as you want.
You have set Force New Page â Before Section
if you want a new page for every member of the group.
I have placed SCH (name of the field of table which have school code) two times because I have to print the header (because repeat section YES do not works, as it is a bug in base report software which have mentioned somewhere on internet) on every group i.e. if a particular schoolâs data expands more than 1 page, on consecutive pages, there should be school header. So, I have placed the same group header, in the first header i have set :
Name : LETFILE1
Force New Page : None
Keep Together : No
Repeat Section : No
Visible : No
Height : 0.03 cm
âŚ
In the next same header which is based on SCH field
Name : LETFILE
Force New Page : Before Section
Keep Together : No
Repeat Section : Yes
Visible : No
Height : 12.57 cm
âŚ
But, I am not able to see the Page Number 1 for next school letter.
Please make a screenshot of your design. If you set the pagebreak to âBefore Sectionâ and let the section be repeated, this will always be â1â as page number.
You have to choose Insert â Page Numbers â Page N
. This number will be reset every time the name of the table appears. So it should be a header, which appears only one time for every group.
Name : NewRow
Force New Page : Before Section
Keep Together : No
Repeat Section : No
Visible : Yes
Height : 0.03 cm
Why do you create a page header with height of 12.57 cm, which shouldnât be visible?
Set the names different for the header with the break. So the macro could find it.
A simple example here. Open the form and press âStart Reportâ in the form.
Test.odb (19.4 KB)
Let me re-elaborate. I am preparing letters for schools in which there will be some rows. In this report, I have two groups on a same field SCH (which is school code). First group (LETFILE1) is not visible and the second one (LETFILE) in which I have placed our company name, address of school, few fixed lines in a lable. Why I have placed two groups because some where in launchpad, it has mentioned that its a bug and workaround is place two group and keep one invisible. Its my typo error that in my last message I said Visible : No for 12.57 cm header, actually its visible is YES, I am sorry for this mistake. As you said, Insert Page Number N, so yes, I have placed that control and it is not getting reset to 1.
One thing I noticed, when I opens your test.odb, it opens Libreoffice security warning for macros, but when I opens my database it do not shows this warning box.
Security warning appears, because it contains macros. The macro I have written is inside the Base document. So you have to allow executing macros.
Have tried a little bit with repeated Group Header. See attached new example. Itâs looking a little bit confusing, but if you repeat the Group Header it will appear in the header of the page, not in content. So the Group Header for changing the page number must be set after the repeated header.
Test.odb (20.4 KB)
Allow to execute macros for this. You couldnât start the report in the form without allowing this.
Check this link which says, if you wish to repeat the group header on each page :
https://bugs.documentfoundation.org/show_bug.cgi?id=82097#c12
Thatâs what I wrote there âŚ