Question about triggers of a Form

tompynationtompynation Member Posts: 398
The OnafterGetRecord trigger, why is this trigger being executed more then once if you stay on the same record?

For example, when you have a form with a tabcontrol on it...
Each time you switch from tab, the OnAfterGetRecord gets executed :?:

Why is this?

Is there any other trigger i could use, wich get called only once?
Untill you go to the next / previous record?

Comments

  • XypherXypher Member Posts: 297
    You could always do something like...
    IF Rec <> xRec THEN BEGIN
      //...
    END;
    

    I think that has worked for me in the past.

    Otherwise you could just create a variable and assign it the primary key value of the current record, and if it re-occurs then don't execute your code.
  • kinekine Member Posts: 12,562
    The OnafterGetRecord trigger, why is this trigger being executed more then once if you stay on the same record?

    For example, when you have a form with a tabcontrol on it...
    Each time you switch from tab, the OnAfterGetRecord gets executed :?:

    Why is this?

    Is there any other trigger i could use, wich get called only once?
    Untill you go to the next / previous record?

    Check "OnAfterGetCurrRecord". The OnAfterGetRecord is called each time the record is displayed.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • garakgarak Member Posts: 3,263
    The work of the OnafterGetRecord trigger is very easy:

    The code in this trigger is executed before it is displayed on form but after the record is retrieved from the table. So, no problem in a TabControl based Form (it shows only one rec). But on a table box form, Navision calls this trigger for each record :!:

    So, when you will only run code on you Current Record in tablebox form, you should use the trigger OnAfterGetCurrRecord.
    The code in this trigger is also executed after the current record is retrieved from the table. So, if you have a table box form, and you have code in this trigger, the system only calls this trigger when it updates the current record in the table box. And this is what you need ;-)

    Regards
    Do you make it right, it works too!
Sign In or Register to comment.