keepWithNext trick

ReinhardReinhard Posts: 290Member
edited 2011-09-06 in NAV Tips & Tricks
Hi... I had this problem and I saw that others have had it too. Basically, when creating a report, you want to avoid a page break between certain sections. But the KeepWithNext property does not help you.

Specifically, it will not keep a "Header" section with a "Body" section, even for the same data item.

So what I did was add in another "Body" section that I only print for the first record, so it behaves like a Header, but keepWithNext will still work.


  • krikikriki Posts: 7,817Member, Moderator
    [Topic moved from 'NAV/Navision' forum to 'NAV Tips & Tricks' forum]
    Regards,Alain Krikilion
    Use the SEARCH,Luke! || No PM,please use the forum. || May the <SOLVED>-attribute be in your title! || Read Forum Rules before making a posting

    »»» Mark your calendar: NAV TechDays 2015 - 19 & 20 November 2015 (!) ««« Visit the conference website:
  • KlebaKleba Posts: 1Member
    Thanks for this helpful post. In addition to this, I had the problem, that I need the heading on the next page again (e.g. when you have a lots of lines after the heading and the lines continue on the nextpage). With a header-section you would have been set "PrintOnEveryPage" = True, but with a body section you have to do a small workaround.

    I did it this way:
    XXX Line, Body (1) - OnPostSection()
    // Don't show generally 
    // Check if it is the first Record
    IF IsFirstRecOfDataItem THEN BEGIN
      IsFirstRecOfDataItem := FALSE;
      // Remember the page
      HeaderLastPrintedOnPage := CurrReport.PAGENO;
      // Was printed on last page? Print again :)
      IF HeaderLastPrintedOnPage &lt;&gt; CurrReport.PAGENO THEN BEGIN
        HeaderLastPrintedOnPage := CurrReport.PAGENO;

    Don't forget to set IsFirstRecOfDataItem and HeaderLastPrintOnPage to correct init-values in the OnPreDataItem.

    Maybe this helps for someone :)
Sign In or Register to comment.