SETSELECTIONFILTER and Total Amount

navuser1navuser1 Member Posts: 1,329
Dear all,

How to use the SETSELECTIONFILTER function to sum up of a columnar value ??

Scenario
Now or Never

Comments

  • kapamaroukapamarou Member Posts: 1,152
    Which form is this?

    You can add a button and write:
    MySumVar := 0;
    CurrForm.SETSELECTIONFILTER(Rec);
    IF FIND('-') THEN REPEAT
    MySumVar += Amount;
    UNTIL NEXT = 0;



    You cannot use CALCSUMS.
  • BeliasBelias Member Posts: 2,998
    i wonder if he wants the sum to be calculated after pressing a button (code of kapamarou in OnPush() ) or if he wants to have the sum calculated in realtime during lines selection (not suggested). in the 2nd option, you should try some other form trigger, and review kapamarou code in order to not use "rec" variable but another variable pointing to the same table (to avoid filer problems)
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • navuser1navuser1 Member Posts: 1,329
    Belias wrote:
    i wonder if he wants the sum to be calculated after pressing a button (code of kapamarou in OnPush() ) or if he wants to have the sum calculated in realtime during lines selection (not suggested). in the 2nd option, you should try some other form trigger, and review kapamarou code in order to not use "rec" variable but another variable pointing to the same table (to avoid filer problems)

    generic Solution is in my mind for the 1st option. But I want to work for the 2nd Option.
    Which Trigger should I try ??? :-k :-k

    BTW Thnx to both :thumbsup:
    Now or Never
  • BeliasBelias Member Posts: 2,998
    navuser1 wrote:
    Belias wrote:
    i wonder if he wants the sum to be calculated after pressing a button (code of kapamarou in OnPush() ) or if he wants to have the sum calculated in realtime during lines selection (not suggested). in the 2nd option, you should try some other form trigger, and review kapamarou code in order to not use "rec" variable but another variable pointing to the same table (to avoid filer problems)

    generic Solution is in my mind for the 1st option. But I want to work for the 2nd Option.
    Which Trigger should I try ??? :-k :-k

    BTW Thnx to both :thumbsup:
    just try them...they're not a lot (i would bet on onaftergetrecord)...anyway, think carefully before implementing the second option: althought it is cool, it can backfire if (for example) the user select all records...imagine how huge it would be on a million o recs...and maybe the user didn't either want that sum...
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • navuser1navuser1 Member Posts: 1,329
    Faced problem in OnAfterGetRecord(); :roll: :roll:
    Now or Never
  • kapamaroukapamarou Member Posts: 1,152
    You should try other triggers. What you are trying to achieve is a bit more complicated than the Gen. Journal form (you should look at this to get an idea from the balance text boxes). But as Belias said, this "automatic" option should better be avoided.
  • navuser1navuser1 Member Posts: 1,329
    kapamarou wrote:
    You should try other triggers. What you are trying to achieve is a bit more complicated than the Gen. Journal form (you should look at this to get an idea from the balance text boxes). But as Belias said, this "automatic" option should better be avoided.

    Suppose I'm using Sales Journal Form where many entries are there. A TextBox will show us the sum calculated on the Basis of Lines Selection. The sum is nothing but the Nos. of Amount fields Total.
    Now or Never
Sign In or Register to comment.