>>>I have a grid which the user can add records to a child table. Does VFP have a method for calculations on columns and/or rows. I would like to sum a numeric column without having to access the child table. Any help is greatly appreciated.
>>>
>>
>>No method so far. I would suggest a custom method be created and do the calculation by SELECT-SQL to make it independent with the source table, thus, no direct access on the data and so record pointer will not change. The Method is actually a wish list of mine on the upcoming version releases because PB Data Window is supporting that feature.
>
>Thanks for the assistance. SQL will work just fine...
>
>Jamie
Jamie,
For rowwise calculation you could use calculated fields (ie: controlsource = field1+field2 - Readonly). For columnwise SQL is the best way. To speed up things :
select sum(myfield) ;
where linkkey = parentPK ;
into array myarray
thisform.sumcolumn.value = iif(type("myarray")="U",0,myarray[1])
nOldValue = nvl(oldval("myfield"),0)
nNewValue = nvl(myfield,0)
thisform.sumcolumn.value = ;
thisform.sumcolumn.value + (nNewValue - nOldValue)
So SQL would only be called if parent rec changes.
Cetin