This is probably not exactly code archive material, but it took me hours to figure it out without finding any examples in here.
I used a naming convention on this form for my numeric fields so income amounts start with i_, deductions with d_ and expenses with e_.
I use this 1 record to create a template table with a fixed number of records for each of the fields on this form. That table is easy to total, but this one was not if changes were made here after posting the template.
NetInc.png
Hope someone finds this useful!
I used a naming convention on this form for my numeric fields so income amounts start with i_, deductions with d_ and expenses with e_.
I use this 1 record to create a template table with a fixed number of records for each of the fields on this form. That table is easy to total, but this one was not if changes were made here after posting the template.
NetInc.png
Code:
dim tbl as p dim vList as c dim iList as c dim eList as c dim dList as c dim totded as n = 0 dim totexp as n = 0 dim totinc as n = 0 dim vTotal as n = 0 topparent.allow_change(.t.) tbl = table.current() vlist = a5_get_fieldnames(tbl.name_get()) dList = *for_each(foo,foo.value,vlist,left(foo.value,2)="d_") 'remove the 2 char fields that use this naming convention dlist = word_remove(dlist,2) dlist = word_remove(dlist,3) eList = *for_each(foo,foo.value,vlist,left(foo.value,2)="e_") iList = *for_each(foo,foo.value,vlist,left(foo.value,2)="i_") for each fld in iList totinc = totinc+eval("tbl."+fld.value) next for each fld in dList totded = totded+eval("tbl."+fld.value) next for each fld in eList totexp = totexp+eval("tbl."+fld.value) next TOTAL_INC.value = totinc TOTAL_DED.value = totded TOTAL_AGI.value = totinc - totded TOTAL_EXP.value = totexp vTotal = totinc - (totded+totexp) net_inc.value = vTotal updated.value = date() topparent.commit()
Comment