How to read last 10 records from a table

dear friends

how to read last 10 records from a table in navision . findlast only takes last record …

1.Creata a variable with integer data type for example(RecCount)

2.Reset your table

3.find last record

4.Incraese your RecCount (RecCount:=RecCount+1)

5.then find the previous record by decreasing the the step (rec.next = -1 )

7.if RecCount reaches 10 the stop your itration

Count := 0;
IF Customer.FIND('-') THEN
REPEAT
RecCount := RecCount + 1;
  if RecCount = 11 then
     exit;
UNTIL Customer.NEXT = -1;

Hi Marshal,

don’t you mean FIND(’+’) and NEXT(-1)=0 ?

Hi Thomas

i mean “” rec.Next = -1 “” this ill take you to the immediate previous record from thee current record.

for example a table have 100 rows and you are in the 100th row then if you use “” rec.Next = -1 “” it ill bring you 99th row.

Thanks

Marshal.J

Dear MARSHAL

sorry to say that its only picking first 10 records

i just tried with a code unit code

RecCount := 0;
IF Customer.FIND(’-’) THEN
REPEAT
RecCount := RecCount + 1;
MESSAGE ('Customer number : %1 and Name : %2 ',Customer.“No.”,Customer.Name);
IF RecCount = 11 THEN

EXIT;
UNTIL Customer.NEXT = -1;

please give me a correct solution

thanks regards

Akhilesh

hi,

try

IF Customer.FIND(’+’) not ‘-’

Hi Akhilesh

Try this

IF Customer.FindFirst Then
IF Customer.NEXT(Cursor) = 0 Then;

//Cursor is the integer type and Where Cursor = Customer.Count - 10;

Do this its working

Cust.RESET;
IF Cust.FIND(’+’) THEN
BEGIN
REPEAT
Count1:=Count1+1;
MESSAGE ('Customer number : %1 and Name : %2 ',Cust.“No.”,Cust.Name);
IF Count1 = 10 THEN
EXIT;
Cust.NEXT(-1);
UNTIL Count1 = 10;
END;

Dear Akileash here after don’t say “”"" Please GIVE correct SOLUTION “”""" Ok

Thanks

Jerome Marshal.j

FINDFIRST and FIND(’-’) will work in this case - but it demands command “Customer.ASCENDING(FALSE)” [H]

thanks marshal…

and

thanks to all…its solved my problem…

regards

Akhilesh