Ok. to create a form property, open your Form and apears the Form menu, there, choose New property, at the dialog box give it a meaningful name
To create a form method, go to the Form menu and select New method
***
To manipulate the record field, use it like an object: MYTABLE.FIELD1
I.E.
xMyValue = MYTABLE.FIELD1
Replace MYTABLE.FIELD1 With xMyValue
Or
Replace FIELD1 With cMyValue In MYTABLE
To save the record pointer, at your method or procedure create a variable to
store the record pointer:
Local nRecord && Variable to save record pointer
nRecord = Recno("MYTABLE") && MYTABLE can be an Tabla Alias
...
* Your Code
Go nRecord In MYTABLE && Or TABLE ALIAS
**************************************************
Well, a more complete sample:
- Create a method and call it like you want (calculations, sums, averages, etc..), here you will calculate your values and make any changes
- If needed, create properties to hold values than will be accesible at all the form.
Imagine than you have a method called Calculations, and you have a table called DETAIL with four fields called ORDER, QTY, COST, PRICE, and you have to multiply QTY * COST and assign the result to PRICE. And too you have other table called CUSORDER with 2 fields: ORDER,TOTAL and want to store the sum of PRICE to it.
At the method Calculations set this
Local nPrice, nSum, nRec
nRec = Recno("DETAIL")
nPrice = DETAIL.QTY * DETAIL.COST
Replace PRICE With nPrice In DETAIL
Sum PRICE All For DETAIL.ORDER = CUSORDER.ORDER To nSum
Replace TOTAL In CUSORDER
Go nReg In DETAIL
Thisform.Refresh() && You must refresh only the controls than have a value change, like textboxes
*********** End of Method Calculations
At the lost focus of COLUMNx.TEXT1 (the columns where QTY and COST where assigned), or If at the valid event after you have validated as a VALID value
call this method:
Thisform.Calculations()
And that's all, for the beginning.
Things to check:
- If you prefer, Select the DETAIL table before make any calculation to assure than you are working with that table.
- Read the documentation, and all the Programmers Guide that comes with the help
- Buy a good book about VFP OOP (look at
www.hentzenwerke.com there are a lot of good books)
- Read the FAQ section here at the UT, specially search for Grids
- Read the UTMagazine/Rapozine here at the UT.
Hope this help
Mauricio
Be fast like the Fox
Be free like the Penguin
Se Rápido como el Zorro
Se libre como el Pingüino