web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Insert Record

(0) ShareShare
ReportReport
Posted on by 3,099

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

I have the same question (0)
  • Suggested answer
    RockwithNav Profile Picture
    9,182 Super User 2026 Season 1 on at

    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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans