>* Method.:txtamt.valid >* Modified 12/26/2002 by CWILLIAMS > >* calculate the total of all non-deleted records >* and calulate the total number of records to display >* a running total of each for all input >* 13=enter key >* 24=downarrow >LOCAL nKey >nKey = LASTKEY() >LOCAL lnTmpTotal,lnToCnt >lnTemp=RECNO() >COUNT FOR !DELETED() TO lnTotCnt >lnTmpTotal=0 >GO TOP >DO WHILE NOT EOF() > IF !DELETED() then > lnTmpTotal=lnTmpTotal+amt > ENDIF > SKIP >ENDDO > >GOTO lnTemp >WITH ThisForm > .txtEnterTotal.VALUE=lnTmpTotal > .txtTotRecCnt.VALUE=lnTotCnt >ENDWITH >* add new record if downarrow or enter key pressed >IF nKey= 13 OR nKey= 24 > KEYBOARD '{DNARROW}' > IF EOF() > GO BOTTOM > APPEND BLANK > ENDIF >ENDIF >THIS.REFRESH >Chuck,
*Initialize - ie: in form.init local array arrCompute[1] set deleted on select sum(amt) from myTable into array arrCompute WITH ThisForm .txtEnterTotal.VALUE=iif(_Tally=0,0,arrCompute) .txtTotRecCnt.VALUE=_Tally ENDWITH *Any code adding to table also calls WITH ThisForm.txtTotRecCnt .VALUE=.Value+1 ENDWITH *Any code deleting from table also calls WITH ThisForm.txtTotRecCnt .VALUE=.Value-1 ENDWITH *TxtAmt.GotFocus this.Tag = trans(this.Value) *TxtAmt.LostFocus WITH ThisForm.txtEnterTotal .VALUE = .Value + (this.Value - val(this.Tag)) ENDWITH if !mdown() and inlist(lastkey(),13) keyboard '{DNARROW}' endif *Grid.AllowAddNew= .t. would handle adding the new record if at bottomCetin