You do not want the subtotal variable to be place in every row.  It will
only update in the row you are currently on. And, if you go back a row it
may increment incorrectly.

Here is the solution I would use.

The target table should have an indexed integer column where you can place a
number unique to this order/subtotal.  Lets say this is OrderID.  All
records to be totaled should have this id.  If this tier is the second table
in a form you may already have that in place.  If this form stands alone you
will have to have a variable defined with this id before you start the form.
Place the id field on the form with a default setting .vID or whatever.

You can have a row exit eep that does
SELECT SUM(AmountCol) INTO vSubtotal FROM tablename WHERE OrderID = .vID
CLS FROM 25 1 TO 25 10
WRI .vSubtotal AT 25 1
SCREEN RESTORE OFF
RETURN

This would type your subtotal at the bottom left of the form.

If this does not always work you may have to also use the same eep as a row
entry eep.

-- Dennis McGrath
mailto:[EMAIL PROTECTED]

-- Productivity Tools for R:Base Programmers
http://www.enteract.com/~mcgrath/dennis

-- Full time consultant with:
SQL Resources Group
Steve Hartmann
Oak Park, IL
mailto:[EMAIL PROTECTED]



-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
Behalf Of randyp
Sent: Sunday, November 04, 2001 3:37 AM
To: [EMAIL PROTECTED]
Subject: RE: Form running total


        I did a little more testing by adding a variable vAmount.
I put it to the right of my column Amount on the tiered form.
When I enter $10.00 in Amount, my vSubtotal = $10.00.
Then I move to the variable field and enter $10.00.
My cursor drops to the next row.
vSubtotal increases to $20.00,
the amount of the variable vAmount of $10.00 is shown
on line two without being entered (because the value was
not reset to null or zero, which could be done in an eep)
and the subtotal for my variable column = $30.00.
The subtotals should both equal $10.00.
I had a computed column in my table but removed it
and it had no effect.
        Randy Peterson

Frank,

        I don't think you need the eep.
        Set a variable in the form to calculate your subtotal.
        I tested a currency column called Amount.

Select Variable, Edit.
Then enter vSubtotal= Currency to establish a currency variable.
[Do not use the = sign, use a space]
(It will not show up as a variable).  Then
vSubtotal = (.vSubtotal  + Amount)

You need to initialize vSubtotal = 0 or set Zero on in order for the
variable to show on the form.  When you open the form it will
show $0.00.

Locate the variable outside your tiered rows.

Each time you leave a row, the subtotal should update and show
correctly.

Actually my subtotal doubled the amount entered.  So in order to
show correctly the formula was vSubtotal = (.vSubtotal + Amount /2)
Which seems totally unexplicable.  But I am using RBWin 6.5+ ...

Could someone proffer a clue on why the entered amount might double?



Reply via email to