how to move to next line in 1 textbox (Report)?

julkiflimanjulkifliman Member Posts: 3
hai...could navision change line?

i want to add purchase comment line in purchase header (Purchase Order Report)

I want to add code like VbCrLf (In visual basic or Visual basic .NET)


PurchaseCommentLine.SETRANGE("Document Type",PurchaseCommentLine."Document Type"::Order);
PurchaseCommentLine.SETRANGE("No.","No.");
IF PurchaseCommentLine.FINDSET THEN
REPEAT
IF PurchaseCommentLine.Comment <> '' THEN
CommentText := CommentText + ' ' + PurchaseCommentLine.Comment;
UNTIL PurchaseCommentLine.NEXT = 0;

--> this ' ' code , how to be change line?

like if we use "ENTER" button in our PC

Comments

  • kinekine Member Posts: 12,562
    in some cases NAV is using "\" as a character for new line. But I am afraid that it will not work in youor scenario. NAV has no support for "multiline" edit boxes (you can enable multiline property, but this is just about "word wrapping").
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • SavatageSavatage Member Posts: 7,142
    It can be done two ways as long as you can limit your comment lines to say"10" max

    One is use an array and a page header loop
    If you have the Purch comment line as a indented dataitem on the report for the Purch header add.

    OnPreDataItem() //of thePurch Comment Line Dataitem
    FOR i := 1 TO 10 DO
      CommentText[i] := '';
    i:= 0;
    

    OnAfterGetRecord()
    i := i + 1;
    CommentText[i] := Comment;
    

    Create muliple pageloop, headers(1) & (2) etc to 10
    in the sections->code add
    OnPreSection()
    IF CommentText[1] = '' THEN
      CurrReport.SHOWOUTPUT := FALSE;
    

    on the pageloop header (2) add
    OnPreSection()
    IF CommentText[2] = '' THEN
      CurrReport.SHOWOUTPUT := FALSE;
    

    Etc, Etc for 3 to 10
    add a text box on each section sourceexp CommentText[1], 2 & 3 for each section.

    it will allow 10 lines of comment text
    I have a report that does this - i can post on the web & post the link if my explanation is not clear.
    another ugly way, personally I would put this in a function "GetComments" and call it from the onaftergetrecord
    getComments;
    FOR x := 1 TO 10 DO BEGIN
    
    PurchCommentLine.SETCURRENTKEY("Document Type","No.","Line No.");
    PurchCommentLine.SETFILTER(PurchCommentLine,"Document Type",PurchHeader."Document Type");
    PurchCommentLine.SETFILTER(PurchCommentLine,"No.",PurchHeader."No.");
    
    IF PurchCommentLine.FIND('-') THEN
      REPEAT
         IF PurchCommentLine."Line No." = 10000 THEN text1 := PurchCommentLine.Comment;
         IF PurchCommentLine."Line No." = 20000 THEN text2 := PurchCommentLine.Comment;
         IF PurchCommentLine."Line No." = 30000 THEN text3 := PurchCommentLine.Comment;
         IF PurchCommentLine."Line No." = 40000 THEN text4 := PurchCommentLine.Comment;
         IF PurchCommentLine."Line No." = 50000 THEN text5 := PurchCommentLine.Comment;
         IF PurchCommentLine."Line No." = 60000 THEN text6 := PurchCommentLine.Comment;
         IF PurchCommentLine."Line No." = 70000 THEN text7 := PurchCommentLine.Comment;
         IF PurchCommentLine."Line No." = 80000 THEN text8 := PurchCommentLine.Comment;
         IF PurchCommentLine."Line No." = 90000 THEN text9 := PurchCommentLine.Comment;
         IF PurchCommentLine."Line No." = 100000 THEN text10 := PurchCommentLine.Comment;
      UNTIL PurchCommentLine.NEXT=0;
    END;
    

    *i guess i could use array to clean that code up :oops:

    Then you can add a textbox with sourceexp text1+text2+text3..etc
    Set tablebox to multiline=yes and make the box big.
    one thing to monitor that if all the comments together are larger than the field can handle then you will get an error, unless you make multiple fields.

    First array method prints the header then loops thru comment lines and add them one after the other - not showing output if it doesn't exist.

    second method forces you to allocate space for the textboxes if the comment exist or not.
    but it's always god to have more than 1 choice. as i said above i have a picking ticket that prints multiple comment lines (max10) i can share as an example if needed (uses array method)

    I hope this is the thing you are trying to make happen???
  • julkiflimanjulkifliman Member Posts: 3
    Savatage wrote:
    It can be done two ways as long as you can limit your comment lines to say"10" max

    One is use an array and a page header loop
    If you have the Purch comment line as a indented dataitem on the report for the Purch header add.

    OnPreDataItem() //of thePurch Comment Line Dataitem
    FOR i := 1 TO 10 DO
      CommentText[i] := '';
    i:= 0;
    

    OnAfterGetRecord()
    i := i + 1;
    CommentText[i] := Comment;
    

    Create muliple pageloop, headers(1) & (2) etc to 10
    in the sections->code add
    OnPreSection()
    IF CommentText[1] = '' THEN
      CurrReport.SHOWOUTPUT := FALSE;
    

    on the pageloop header (2) add
    OnPreSection()
    IF CommentText[2] = '' THEN
      CurrReport.SHOWOUTPUT := FALSE;
    

    Etc, Etc for 3 to 10
    add a text box on each section sourceexp CommentText[1], 2 & 3 for each section.

    it will allow 10 lines of comment text
    I have a report that does this - i can post on the web & post the link if my explanation is not clear.
    another ugly way, personally I would put this in a function "GetComments" and call it from the onaftergetrecord
    getComments;
    FOR x := 1 TO 10 DO BEGIN
    
    PurchCommentLine.SETCURRENTKEY("Document Type","No.","Line No.");
    PurchCommentLine.SETFILTER(PurchCommentLine,"Document Type",PurchHeader."Document Type");
    PurchCommentLine.SETFILTER(PurchCommentLine,"No.",PurchHeader."No.");
    
    IF PurchCommentLine.FIND('-') THEN
      REPEAT
         IF PurchCommentLine."Line No." = 10000 THEN text1 := PurchCommentLine.Comment;
         IF PurchCommentLine."Line No." = 20000 THEN text2 := PurchCommentLine.Comment;
         IF PurchCommentLine."Line No." = 30000 THEN text3 := PurchCommentLine.Comment;
         IF PurchCommentLine."Line No." = 40000 THEN text4 := PurchCommentLine.Comment;
         IF PurchCommentLine."Line No." = 50000 THEN text5 := PurchCommentLine.Comment;
         IF PurchCommentLine."Line No." = 60000 THEN text6 := PurchCommentLine.Comment;
         IF PurchCommentLine."Line No." = 70000 THEN text7 := PurchCommentLine.Comment;
         IF PurchCommentLine."Line No." = 80000 THEN text8 := PurchCommentLine.Comment;
         IF PurchCommentLine."Line No." = 90000 THEN text9 := PurchCommentLine.Comment;
         IF PurchCommentLine."Line No." = 100000 THEN text10 := PurchCommentLine.Comment;
      UNTIL PurchCommentLine.NEXT=0;
    END;
    

    *i guess i could use array to clean that code up :oops:

    Then you can add a textbox with sourceexp text1+text2+text3..etc
    Set tablebox to multiline=yes and make the box big.
    one thing to monitor that if all the comments together are larger than the field can handle then you will get an error, unless you make multiple fields.

    First array method prints the header then loops thru comment lines and add them one after the other - not showing output if it doesn't exist.

    second method forces you to allocate space for the textboxes if the comment exist or not.
    but it's always god to have more than 1 choice. as i said above i have a picking ticket that prints multiple comment lines (max10) i can share as an example if needed (uses array method)

    I hope this is the thing you are trying to make happen???

    Ok thanks a lot Savatage
    I changet my mind
    i use array like you told me
    I set there's only 5 line default for the comment
    thank you for your answer :)
Sign In or Register to comment.