>Hi Marcia,
>Thanks for replying,
>Yes, what I'm doing here is making a view as a grid's recordsource, and I wrote a code like this,
>
>PROCEDURE Grid1.Init
>
>LOCAL lcname
>lcname=THIS.PARENT.NAME
>WITH THIS
>.RECORDSOURCE='accounting'
>.RECORDSOURCETYPE=1
>.COLUMN1.CONTROLSOURCE='accounting.cat'
>.COLUMN2.CONTROLSOURCE='accounting.date'
>.COLUMN3.CONTROLSOURCE='accounting.payee'
>.COLUMN4.CONTROLSOURCE='accounting.subout'
>.COLUMN5.CONTROLSOURCE='accounting.subin'
>.COLUMN6.CONTROLSOURCE='THISFORM.&lcname..GRID1.BALANCE()'
>ENDWITH
>
>ENDPROC
>
>PROCEDURE Grid1.Balance
>SELECT Accounting
>
>lnBalance = subin - subout
>
>SKIP -1
>IF !BOF()
>lnBalance = lnBalance + balance
>SKIP 1
>ELSE
>GO TOP
>ENDIF
>
>IF !lnBalance = balance
>REPLACE balance WITH lnBalance
>ENDIF
>
>RETURN lnBalance
>
>THIS.Column4.Text1.Valid()
>THIS.Column5.Text1.Valid()
>ENDPROC
>
>PROCEDURE Text1.Valid (For Col4 & Col5)
>IF !balance = THIS.Parent.Parent.Balance()
>THIS.Parent.Parent.Column6.Refresh()
>ENDIF
>ENDPROC
>
>Accounting SQL-select
>
>CREATE SQL VIEW AS Select Cash_account.cat, Cash_account.date, Cash_account.payee, Cash_account.subout, Cash_account.subin,0000000000.00 AS balance ;
> FROM Main!Cash_account ORDER by Cash_account.Date
>
>
>Hope you can gimme any suggestion,
>TIA :-)
Senna,
Balance kind of a running total ? You already have a balance field in view, why not use it.
PROCEDURE Grid1.Init
WITH THIS
.RECORDSOURCE='accounting'
.RECORDSOURCETYPE=1
.COLUMN1.CONTROLSOURCE='accounting.cat'
.COLUMN2.CONTROLSOURCE='accounting.date'
.COLUMN3.CONTROLSOURCE='accounting.payee'
.COLUMN4.CONTROLSOURCE='accounting.subout'
.COLUMN5.CONTROLSOURCE='accounting.subin'
.COLUMN6.CONTROLSOURCE='accounting.balance'
ENDWITH
ENDPROC
PROCEDURE Text1.gotfocus (For Col4 & Col5)
this.tag = str(this.value)
ENDPROC
PROCEDURE Text1.LostFocus (For Col4)
if val(this.tag) # this.value
lnDelta = this.value - val(this.tag)
lnRecNo = recno()
replace balance with balance + lnDelta while !eof()
go lnRecNo
endif
ENDPROC
PROCEDURE Text1.LostFocus (For Col5)
if val(this.tag) # this.value
lnDelta = this.value - val(this.tag)
lnRecNo = recno()
replace balance with balance - lnDelta while !eof()
go lnRecNo
endif
ENDPROC
CREATE SQL VIEW AS ;
Select Cash_account.cat, Cash_account.date, ;
Cash_account.payee, Cash_account.subout, ;
Cash_account.subin,0000000000.00 AS balance ;
FROM Main!Cash_account ;
ORDER by Cash_account.Date
lnBalance = 0
scan
lnBalance = lnBalance + ( subin - subout )
replace balance with lnBalance
endscan
go top
Cetin