What is wrong here?

I’m just a beginner, and try to write some code for training. I can’t figure out why this code doesn’t work: Customer.SETCURRENTKEY("Credit Limit (LCY)"); Customer.SETRANGE("Credit Limit (LCY)",0); IF Customer.FIND('-') THEN REPEAT Customer.CALCFIELDS(Balance); IF Customer.Balance=0 THEN Customer."Credit Limit (LCY)":=10000 ELSE Customer."Credit Limit (LCY)":=Customer.Balance*10; Customer.MODIFY; UNTIL Customer.NEXT=0 When I run it, it modifies only the first found record! Where is the mistake? Please, please help me. >>>> maggie please use the and tags when writing code.

Don’t worry, this is beyond the basics. When you modify the record it gets a new posision in the table according to the key you are using. It will get a balance of, say 10000, and therefor the rec.Next will return zero. To avoid this (and other alike issues) you should always modify a copy of the record; ... If Customer.Balance=0 then begin Customer2.get(Customer."No."); if Customer.Balance=0 THEN Customer2."Credit Limit (LCY)" := 10000 ELSE Customer2."Credit Limit (LCY)" := Customer.Balance*10; Customer2.modify; Until Customer.NEXT = 0;

Thank you very much indeed! Come to think of it, it makes sense. But it was an exercise from the book Navision Development, and I thought it had to be easy. Thanks again.