records modifications

sbillysbilly Member Posts: 231
Hi all,
I have a table with many lines. Only the "Entry No." is diffrent between lines.
I have many identical lines 2 by 2, only the "Entry No." is diffrent.
And I want to modify every second line of these 2 lines.
I hope that u understand what I want to do.
I created a report but it changes the 2 lines.
Thanks

Comments

  • Big_DBig_D Member Posts: 207
    Hi sbilly

    You can have something like...

    loop := 0
    IF EntryRec.FINDFIRST then
    repeat
    loop += 1;
    IF (loop MOD 2) = 0 THEN
    //modify 2nd record code

    until EntryRec.NEXT = 0;


    Good luck
    Big D signing off!
  • David_SingletonDavid_Singleton Member Posts: 5,479
    sbilly wrote:
    Hi all,
    I have a table with many lines. Only the "Entry No." is diffrent between lines.
    I have many identical lines 2 by 2, only the "Entry No." is diffrent.
    And I want to modify every second line of these 2 lines.
    I hope that u understand what I want to do.
    I created a report but it changes the 2 lines.
    Thanks

    [-X

    sbilly, you should never be modifying entry tables directly.
    David Singleton
  • Big_DBig_D Member Posts: 207
    Hi sbilly

    You didn't mention Entry tables did you :)!

    Good luck
    Big D signing off!
  • vijay_gvijay_g Member Posts: 884
    Big D wrote:
    Hi sbilly

    You didn't mention Entry tables did you :)!

    Good luck
    Is there any other table in navision having entry no. field(other than ledger table)? :-k
  • krikikriki Member, Moderator Posts: 9,110
    And using FINDFIRST in a LOOP is not a good idea.

    Better would be:
    loop := 0
    IF EntryRec.FINDSET(TRUE,TRUE) then
    repeat
      loop += 1;
      IF (loop MOD 2) = 0 THEN BEGIN
        EntryRec2 := EntryRec;
        Change EntryRec2; 
      END;
    until EntryRec.NEXT = 0;
    
    The second TRUE in FINDSET(TRUE,TRUE) + using a second variable is maybe a little overkill, but it is definitely worth it using this technique to avoid possible problems that might arise if not using it. (problems like records that are skipped or changed multiple times,...)
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.