Code to go to the last register inserted

DarkHorseDarkHorse Member Posts: 389
Hello, I'd like to know which code I have to insert in a Form so that always go to the last register inserted each time that it runs.
Thanks.

Comments

  • McClaneMcClane Member Posts: 40
    If your primary Key(s) are set atomatically, set Ranges on it and find('+'). If you set the key(s) manually, you could add a field with a timestamp and find the newest entry searching over it.
  • DarkHorseDarkHorse Member Posts: 389
    Thanks for your reply. The problem it's that the report ejects from a codeunit, it make's a process and when it end's I put form1.RUN; and it goes to the form, but it's positioned at the beggining but I want that it positioned at end of the form, then I have to put it in code. How can I do it?.
    Thanks.
  • kinekine Member Posts: 12,562
    1) There is property for this on the form - you can select if you want to poition the cursor to first,last, previous record - but it is form wide (e.g. dangerous if set on Lookup form).

    2) When running the form, you can pass the record, and if you do FINDLAST (or FIND('+')) on the recod, the cursor will be there (if not overriden by the property from point 1)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • DarkHorseDarkHorse Member Posts: 389
    Thanks both for your help. I'll try it.
    Thank you very much.
Sign In or Register to comment.