Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

Insert Record

(0) ShareShare
ReportReport
Posted on by 3,027

Hi

  I have Main Form (Location) & SaleDeposit SubForm (Source table is SaleDepositLines) . I have 1 Button . On Push Trigger of Button

I want those lines  which have ReceiptAmount > 0 should be inserted in same table SaleDepositLines.  I am trying below code but not working

CDLine refers to the same table which Subform refers to 


CDLine.RESET;
CDLine.SETRANGE("Location.","No.");
CDLine.SETFILTER("receipt Amount",'<>%1',0);
IF CDLine.FINDFIRST THEN BEGIN
REPEAT
CDLine.INIT;
EntryNo := EntryNo + 1;
CDLine.VALIDATE("Entry No.",EntryNo);
CDLine.VALIDATE("Location","No.");
CDLine.VALIDATE("Posted Amount", CDLine."Receipt Amount");
CDLine.INSERT;
UNTIL CDLine.NEXT = 0;
END;

Thanks

*This post is locked for comments

  • Verified answer
    RockwithNav Profile Picture
    RockwithNav 6,562 on at
    RE: Insert Record

    CDLine.RESET;
    CDLine.SETRANGE("Location.","No.");
    CDLine.SETFILTER("receipt Amount",'>%1',0); I changed it to greater then 0 otherwise it will consider negative values too.
    IF CDLine.FINDFIRST THEN BEGIN
    REPEAT
    CDLine2.INIT; //I will recommend to make aa new variable as CDline2
    EntryNo := EntryNo + 1; // Make it findlast then increment it with SETCURRENTKEY so that you have sorting.
    CDLine2.VALIDATE("Entry No.",EntryNo);
    CDLine2.VALIDATE("Location","No.");
    CDLine2.VALIDATE("Posted Amount", CDLine."Receipt Amount");
    CDLine2.INSERT;
    UNTIL CDLine.NEXT = 0;
    END;

    Try this.

    What was the error you were getting?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,711 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,458 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans