keepWithNext trick

ReinhardReinhard Member Posts: 249
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.

Comments

  • krikikriki Member, Moderator Posts: 9,112
    [Topic moved from 'NAV/Navision' forum to 'NAV Tips & Tricks' forum]
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • KlebaKleba Member Posts: 1
    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 
    CurrReport.SHOWOUTPUT(FALSE);
    
    // Check if it is the first Record
    IF IsFirstRecOfDataItem THEN BEGIN
      CurrReport.SHOWOUTPUT(TRUE);
      IsFirstRecOfDataItem := FALSE;
      // Remember the page
      HeaderLastPrintedOnPage := CurrReport.PAGENO;
    END ELSE BEGIN
      // Was printed on last page? Print again :)
      IF HeaderLastPrintedOnPage <> CurrReport.PAGENO THEN BEGIN
        CurrReport.SHOWOUTPUT(TRUE);
        HeaderLastPrintedOnPage := CurrReport.PAGENO;
      END;
    END;
    

    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.