Dear User,
I have make one table in which i have added 1 field period length on basis of that lines are created on other table for eg. if i give period length 10 then 10 lines are generated in another table but now thing Is if i give period length 12 it shows error but if i use deleteall function it works fine but i don’t want to delete all the line because i have provided quantity in that.please help me out with the solution.
How are you checking the period length?
Can you show us the code?
RecTask2.RESET;
RecTask2.SETRANGE(RecTask2.“Document No.”,“No.”);
IF RecTask2.FIND(’-’) THEN BEGIN REPEAT
Day := “Period Length” + DATE2DMY(RecTask2.“Start Date”,1);
Month := DATE2DMY(RecTask2.“Start Date”,2);
Year := DATE2DMY(RecTask2.“Start Date”,3);
RecTask2.“End Date” := DMY2DATE(Day,Month,Year);
RecTask2.MODIFY;
UNTIL RecTask2.NEXT=0;
END;
RecTaskC.DELETEALL;
j:=10000;
RecTask2.RESET;
RecTask2.SETRANGE(RecTask2.“Document No.”,“No.”);
FOR i := 1 TO “Period Length” DO BEGIN
IF RecTask2.FINDFIRST THEN BEGIN REPEAT
RecTaskC.INIT;
RecTaskC.“Document No.” :=RecTask2.“No.”;
RecTaskC.“Item No.” := RecTask2.“Item No.” ;
RecTaskC.“Line No.” := i * j;
RecTaskC.“No Of Days” := i;
RecTaskC.INSERT;
UNTIL RecTask2.NEXT=0;
END;
END;
Hi Abuzar,
Try adding a conditional format to your INSERT command, like this
IF NOT RecTaskC.INSERT THEN;
That should resolve issues you’re having related to trying to insert over the top of existing records.
BTW, and this is just a suggestion, you might take a look at some of the threads related to coding standards and naming conventions. While Hungarian notation, camel-casing, etc. are common in other MS languages, that’s not the case with NAV. The goal is to make your code look just like the base NAV code.
Thank u sir it got resolved i have used if else condition on the above code [:)]
Why have to added Begin before Repeat in your code.
If you remove begin then also the records will be fetched.