Reading Records from recordref

JoshuaSavesJoshuaSaves Member Posts: 15
I have a test table in NAV 4.03. This table contains 2 records. What I am attempting to do is to use recordref to find the last record so that I can increase the integer primary key field by 1. The function once running would then be modified to accept a table number as a paramter and return the next number.

When I use the code below, it never finds a record even though it exists.


RecRef.OPEN(TableNo,FALSE);
IF RecRef.FINDLAST THEN BEGIN
...
END;

Answers

  • girish.joshigirish.joshi Member Posts: 407
    Try removing the if then structure so your code returns an error. It should give you some information about what's going wrong.
  • Revolution1210Revolution1210 Member Posts: 161
    Your code looks correct.

    Try this and see what it returns:
    RecRef.OPEN(TableNo,FALSE);
    MESSAGE('The %1 table contains %2 records',RecRef.CAPTION,RecRef.COUNTAPPROX);
    
    Ian

    www.NextEqualZero.com
    A technical eye on Dynamics NAV
  • JoshuaSavesJoshuaSaves Member Posts: 15
    The only thing I had to change was to insert a line of code to close the RecRef before opening it. I'm not sure why, but it worked.
Sign In or Register to comment.