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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Loop through Records

(0) ShareShare
ReportReport
Posted on by 3,099

Hi

  I am looping thru all Custoemr records . Is it correct way . Customer_rec is of Record Datatype of Customer

    Customer_Rec.RESET;
    Customer_Rec.FINDFIRST;
    REPEAT
      Amt := 0;
      DbAmt := 0;
      CrAmt := 0;
      GlEntry.SETRANGE("Source No.",Customer_Rec."No.");
      IF GlEntry.FINDFIRST THEN REPEAT
        Amt += GlEntry.Amount;
      UNTIL GlEntry.NEXT=0;
      IF Amt > 0 THEN BEGIN
        DbAmt := Amt;
        CrAmt := 0;
        G_Debit += DbAmt;
      END;
      IF Amt < 0 THEN BEGIN
        DbAmt := 0;
        CrAmt := Amt;
        G_Credit += CrAmt;
      END;
    UNTIL Customer_Rec.NEXT = 0;

Thanks


*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Stefano Demiliani Profile Picture
    37,166 Most Valuable Professional on at

    Best way:

    IF CustomerRec.FINDSET THEN

    REPEAT

    ...

    UNTIL CustomerRec.NEXT=0.

  • Community Member Profile Picture
    on at

    I'd suggest naming variables like 'recCustomer' you may find it easier to type than Customer_Rec after a while. 

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

#1
HoangNam Profile Picture

HoangNam 7

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans