SETSELECTIONFILTER for table sum?

Hi,
i like to add a small code to a Form. Goal: the user select 1 to ? lines in a table and under the table i have a sum for this selection.


OnAfterGetCurrRecord:

CurrForm.SETSELECTIONFILTER(TerminBauteil2);
dickesum := 0;
IF TerminBauteil2.FINDSET THEN
REPEAT
dickesum += TerminBauteil2."Dicke (mm)";
UNTIL TerminBauteil2.NEXT = 0;

Problem: The sum is not correct. Most times the last selected or deselected row is not included. Or if i select 4 Lines at once i have only the sum for 1 Line... after clicking on another line the sum is from the last 4 lines?!
If i put the code on a extra button, it is working. It Looks like the table have to lost the Focus for exact Response?

Have somebody a trick or Workaround for this?

NAV Version 4.0 :neutral:

many thanks
Mathias

Answers

  • vaprogvaprog Member Posts: 1,140
    There is no trigger that gets called on selection events. It looks like the line is (lines are) not yet selected when the OnAfterGetCurrRecord trigger is fired. Moreover, this trigger probably does not get called at all if the line has the focus even before it gets selected.

    I don't think there is any way of achieving correct automatic calculation other than by using a timer, or some other automation with events.
Sign In or Register to comment.