CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2009
    Posts
    6

    [RESOLVED] Compute 2 columns

    I have 2 columns Received and Issued, what I want is to compute the 2 columns and show the result on Balance column.

    for example:


    i have a beginning balance of 100

    I input 10 on received and no input on issued column on row(a)

    now, if the issued column is equal to 0 then received
    column will add to the beginning balance. and now the balance
    is 110 on the row(a) where I input the "10".

    Now, I input 30 on issued column and no input on recieved column on row(b)

    then if the received column is 0 then issued column will subtract
    to the balance of row(a) and the difference on Balance Column row(b) will be 80.


    Anyone help me here. ..please. .

    I need it on my report. .

    Thanks in advance

  2. #2
    Join Date
    Jul 2005
    Posts
    1,083

    Re: Compute 2 columns

    You need 2 or 3 formula fields

    Formula1 (this is the formula name)
    Where You assign the initial Balance value
    Could be a Field or a Parameter or a Constant
    (you didn't say from where you take it)
    Place it in the RH or GH section
    Code:
    WhilePrintingRecords;
    numberVar Balance:=100;
    Formula2
    Where You calculate the Balance
    Place it in the Detail Section (this is your balance column)
    Code:
    WhilePrintingRecords;
    numberVar Balance;
    Balance:=Balance + {Table.Received} - {Table.Issued};
    Balance;
    Just change the table and fields names for real ones

    If You need to reset to zero the Balance, let's say at GF section, then you'll need the
    Formula3
    Where You reset to zero
    Place it at GF section
    Code:
    WhilePrintingRecords;
    numberVar Balance:=0;
    JG

  3. #3
    Join Date
    Jul 2009
    Posts
    6

    Question Re: Compute 2 columns

    thanks for help Mr. jggtz

    but there's one more problem . . . on issued column there is a negative value. . and the balance still adding the negative. . . not subtracting it. .

    how can i make the negative value become positive value. . ??

    is it possible to make. .??

    if not. .please help me. . .


    thanks in advance. .

  4. #4
    Join Date
    Jul 2005
    Posts
    1,083

    Re: Compute 2 columns

    Just change the operation sign
    Code:
    WhilePrintingRecords;
    numberVar Balance;
    Balance:=Balance + {Table.Received} + {Table.Issued};
    Balance;
    JG

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured