Announcements
No record found.
Hello Expert,
I am trying to find last second record of the table but my program is not working. Can anyone please help.
Count1:=0;IF Cust.FIND('+') THEN REPEAT Count1:= Count1 +1; UNTIL Cust.NEXT= -1;
Thanks in advance.
Nia
Why not just use FINDLAST
dynamicsuser.net/.../query-on-find-findset-findfirst-findlast
You can loop backwards using the below record or you could set the SETASCENDING to false on the key and loop
IF Cust.FINDLAST THEN
REPEAT
UNTIL Cust.NEXT(-1) = 0;
Hi Suresh,
i tried your code and even i had almost same code but result runs in loop. I want to show only single record and then the function should exit.
MESSAGE(Cust."No.");
Count1:=0;
IF Cust.FIND('+') THEN
Cust.NEXT:= -1;
i tried above and could achieve the result but it shows the record multiple times.
Nia, it will not just exit the look, you need to add the condition like this or when you get your record assign a boolean to true and add that after the next condition..
i := 0
i += 1;
IF i =2 THEN BEGIN
END;
UNTIL (Cust.NEXT(-1) = 0) or (i =2);
Hi Nia,
The following code will work perfectly whenever you want to find the second last record and no looping required at all. When you use my code you have to use at least 2 variables of record type for the same table. {example using the customer table}
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.
Congratulations to our 2026 Super Stars!
Thanks to all of our 2025 Community Spotlight stars!
These are the community rock stars!
Stay up to date on forum activity by subscribing.
OussamaSabbouh 2,091 Super User 2026 Season 1
YUN ZHU 1,032 Super User 2026 Season 1
Dhiren Nagar 946 Super User 2026 Season 1