NILKAMAL

hi!

i know this easy question for other but i am new in foxpro

how do i do calculation of two field in form

e.g field a + fieldb

field c = fieldA+fieldB

let me know which book good for me to learn foxpro

thanks

### Re: subtotal field

Alex Feldstein

LOCAL nfieldC as INT

m.nfieldC = TableAlias.fieldA + TableAlias.fieldA

to update record directly (using XBASE notation as oppossed to SQL UPDATE - also doable):

* navigate to proper record, then:

REPLACE table.fieldC WITH table.fieldA + table.fieldB

or from memvar:

REPLACE table.fieldC WITH m.nfieldC

The best place for FoxPro books is Hentzenwerke:

http://www.hentzenwerke.com/catalog/zcatalog.htm

### Re: subtotal field

dni

What are "fieldA" & "fieldB" on form Textboxes

If they are texboxes you may put :

thisform.fieldC.Value = thisform.fieldA.Value + thisform.fieldB.Value

in method LostFocus of "fieldB" or in method GotFocus of "fieldC" or make a button and put it in click method.

If they are table fields you may create a button and in click method put:

fieldC = fieldA+fieldB

but you will need a texbox to see on form result in fieldC.

http://programatium.com/en/db/foxpro.htm

### Re: subtotal field

Naomi Nosonovsky

If you want a textbox on a form to reflect changes made in two other textboxes, you may put in textbox1 GotFocus

Code Snippet

this.tag = str(this.value)

In the Valid method of the textbox put

Code Snippet

if not this.tag == str(this.value)

thisform.UpdateTotal()

endif

Same for the second textbox.

UpdateTotal would be a new method for the form with the code like this

Code Snippet

thisform.txtTotal.value = thisform.textbox1.value + thisform.textbox2.value

thisform.txtTotal.refresh() && this may be not needed

You may create UpdateTotal method in your form by going to Form menu, New Method.

NILKAMAL