|
Home > Archive > dBASE Programming > March 2005 > Sum fields
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| Moses Hanna 2005-03-28, 6:10 pm |
| Hi everyone
I have a form with a grid containing a grandchild. it contains numeric
field ["qtyIn"] and a numeric fields["qtyOut"].
On selection of a parent I want to sum the QtyIn to a entryfield and the
QtyOut to another field.
If all the rows in the grandchild have only QtyIn Values and no row with a
value in the QtyOut field, the calculation come OK. But as soon as I add a
row with a value in the QtyOut field. the calculation stops and all the
result are 0.
Function calculate
local qt
qt = form.sellitemsdatamodule1.inventory1.rowset // the grandchild
table
qt.first()
xqtyin = 0 // variable to hold the accumelated amounts
do while not qt.endofset
xqtyin = xqtyin +
form.sellitemsdatamodule1.inventory1.rowset.fields["qtyin"].value // I have
used the += with same results
msgbox(str(xqtyin)) // always reads the accumulated total of the
QtyIn values
qt.next()
enddo
msgbox(str(xqtyin)) // If there is no row with values in the
QtyOut field, the msg reads the correct accumulated total.... But as soon
// as there is a row with value in
the QtyOut field, this message reads 0.
//form.cntr3.qtyintl.value := xqtyin
return
if needed I will attach the tables, the datamodule and the form.
thanks for solving this puzzle
Moses
| |
|
|
"Moses Hanna" <moseshanna@optusnet.com.au> wrote in message
news:Oc6PwzRLFHA.320@news-server...
> Hi everyone
> I have a form with a grid containing a grandchild. it contains numeric
> field ["qtyIn"] and a numeric fields["qtyOut"].
> On selection of a parent I want to sum the QtyIn to a entryfield and the
> QtyOut to another field.
> If all the rows in the grandchild have only QtyIn Values and no row with a
> value in the QtyOut field, the calculation come OK. But as soon as I add a
> row with a value in the QtyOut field. the calculation stops and all the
> result are 0.
----
If when you enter a row with a value in the QtyOut field and you do not
enter a value in the QtyIn field then you are probably getting a sum of 0
because the QtyIn field has a null value and anything added to null results
with null. Try substituting a 0 when the value is null.
>
> Function calculate
> local qt
> qt = form.sellitemsdatamodule1.inventory1.rowset // the grandchild
> table
> qt.first()
> xqtyin = 0 // variable to hold the accumelated amounts
> do while not qt.endofset
> xqtyin = xqtyin +
> form.sellitemsdatamodule1.inventory1.rowset.fields["qtyin"].value // I
> have
> used the += with same results
> msgbox(str(xqtyin)) // always reads the accumulated total of the
> QtyIn values
> qt.next()
> enddo
> msgbox(str(xqtyin)) // If there is no row with values in the
> QtyOut field, the msg reads the correct accumulated total.... But as soon
> // as there is a row with value in
> the QtyOut field, this message reads 0.
>
>
> //form.cntr3.qtyintl.value := xqtyin
> return
>
> if needed I will attach the tables, the datamodule and the form.
> thanks for solving this puzzle
> Moses
>
>
| |
| Moses Hanna 2005-03-28, 6:10 pm |
| Hi Ken
Thank you for this valuable information. I didn't realise that the null
value is not as zero value and it is treated the way you said.
Moses
"Ken B" <bogus@nowhere.com> wrote in message
news:sXhNxViLFHA.444@news-server...
>
> "Moses Hanna" <moseshanna@optusnet.com.au> wrote in message
> ----
> If when you enter a row with a value in the QtyOut field and you do not
> enter a value in the QtyIn field then you are probably getting a sum of 0
> because the QtyIn field has a null value and anything added to null
results
> with null. Try substituting a 0 when the value is null.
>
|
|
|
|
|