matrix box

surisuri Member Posts: 123
hi good morning one and all
i have question like this
Create a Matrix box with customers on rows and sales people on Columns and sales amount for each combination

i have taken a new form with source expression sales person/purchaser and record type of customer
i have taken one function amount() with return type text

i have written the code in the function and i have assigned the total sales variable as source expression of text box

cust.RESET;
cust.SETCURRENTKEY(cust."No.");
cust.SETRANGE(cust."No.",Code);
cust.SETRANGE(cust.Name,Name);
cust.SETRANGE(cust."No.",CurrForm.matrixbox.MatrixRec."No.");
IF cust.FINDFIRST THEN
REPEAT
cust.CALCFIELDS(cust."Sales (LCY)");
totalsales :=totalsales+cust."Sales (LCY)";
UNTIL cust.NEXT=0;
exit(format(totalsales));

the out put what i am getting is

Comments

  • krikikriki Member, Moderator Posts: 9,112
    Did you check this : http://www.mibuso.com/howtoinfo.asp?FileID=13 ?

    And 2:
    cust.RESET;
    cust.SETCURRENTKEY(cust."No.");
    cust.SETRANGE(cust."No.",Code);
    cust.SETRANGE(cust.Name,Name);
    cust.SETRANGE(cust."No.",CurrForm.matrixbox.MatrixRec."No.");
    

    First you put this this filter on "No.":
    cust.SETRANGE(cust."No.",Code);

    and now you overwrite the filter:
    cust.SETRANGE(cust."No.",CurrForm.matrixbox.MatrixRec."No.");[/code]


    You need something like:
    totalsales := 0;
    cle.RESET;
    IF NOT cle.SETCURRENTKEY("Customer No.","Salesperson Code") THEN 
      cle.SETCURRENTKEY("Customer No.");
    cle.SETRANGE("Customer No.",Code);
    cle.SETRANGE("Salesperson Code",CurrForm.matrixbox.MatrixRec."No.");
    IF cle.FINDSET THEN // NEVER use FINDFIRST for a REPEAT-UNTIL
      REPEAT
         totalsales := totalsales + cust."Sales (LCY)";
      UNTIL cle.NEXT=0;
    
    exit(format(totalsales));
    
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.