Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Record is in use by another user
Message
From
05/12/1998 12:53:40
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
05/12/1998 12:30:23
Senna Dwipayana
Indo Rebel Apparel Cv
Bandung, Indonesia
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00164389
Message ID:
00164473
Views:
27
>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)  && Use tag property as a storage
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

*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

lnBalance = 0
scan
  lnBalance = lnBalance + ( subin - subout )
  replace balance with lnBalance
endscan
go top
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform