* thisform.txtSum is the control showing sum * * custom method SumMyField updating sum for parent rec change * lParameters tuParKey, tcPKField, tcMyField, tcMyChild select sum(tcMyField) ; from (tcMyChild) ; where &tcPKField = tuParKey ; into array aSumOf return iif(type("aSumOf")="N",aSumOf[1],0) * * any button.click causing parent rec change * default code thisform.txtSum.value = ; thisform.SumMyField("ALFKI","Cust_id","order_amt","orders") * In fact txtSum could be based on a textbox class * having custom methods as Update_ParentChanged, * props LinkKeyFieldName, SumFieldName, SumTableName * so Update_ParentChanged code would be something like : * this.value = ; thisform.SumMyField( ; customer.cust_id, ; this.LinkKeyFieldName, ; this.SumFieldName, ; this.SumTableName) * Here the important point is : There is a custom method * doing SQL sum <b>only</b> when parent rec changes * There is <b>no need</b> to resum as rec contents change in child sumfield * Also if there were a lot of child recs per particular parent, * it would definitely be a performance penalty to do sum again * while parent rec haven't changed at all. * * Now up to this point we only summed a child field as parent rec * changes and wrote the value to thisform.txtSum control * As grid SumField content changes it should be updated to reflect the new sum * Grid.SumField.valid - Or lostfocus as I prefer in fact local lcFieldName,lcAliasName,lnOldValue lcFieldName = substr(this.controlsource, ; rat(".",this.controlsource)+1) lcAliasName = substr(this.controlsource, ; 1, rat(".",this.controlsource)-1) lnOldValue = oldval(lcFieldName,lcAliasName) thisform.txtSum.value = thisform.txtSum.value + ; (this.value - iif( isnull(lnOldValue), 0, lnOldValue) )I hope it's clear now and helps.