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
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}
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
IF Cust.FINDLAST THEN
REPEAT
i += 1;
IF i =2 THEN BEGIN
END;
UNTIL (Cust.NEXT(-1) = 0) or (i =2);
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.
You can loop backwards using the below record or you could set the SETASCENDING to false on the key and loop
UNTIL Cust.NEXT(-1) = 0;
Why not just use FINDLAST
dynamicsuser.net/.../query-on-find-findset-findfirst-findlast
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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Nimsara Jayathilaka. 3,885
Rishabh Kanaskar 3,405
Sumit Singh 2,837