>Hello comunity
>
>i have this code to make a calculation on my grid form changing the controlsource .
>STORE "" TO clname
>FOR EACH myform IN _Screen.forms
> IF UPPER(myform.name)="SFT"
> WITH myform.Pageframe1.Page1.Cont1.Grid1
> FOR i=1 TO .columnCount
> IF UPPER(.Columns(i).ControlSource)="FI.U_VALHUM"
> clname=.Columns(i).name
> .Columns(i).ControlSource = ('((0+fi.u_nospeso-fi.u_VLDscemb)*fi.u_hum)/100')
> exit
> ENDIF
> NEXT i
> EXIT
> ENDWITH
> ENDIF
>NEXT myform
>The original controlsource of my column is a table field FI.U_VALHUM, well , if i use this code effectively i have on my column the result, but, because i change the ControlSource when i save my invoice and i close the invoice form , when a reopen my form the calculate value has dissapear , i think that because the controlsource of my calculation column don´t refer to my table field FI.U_VALHUM and saving the invoice this table field has never hold the calculate value on the table.
>
>I don´t know if i have another possibilities to save the calculate value on my table but using this code to calculate on my column :
>('((0+fi.u_nospeso-fi.u_VLDscemb)*fi.u_hum)/100')
>
>I think if i don´t change the control source, but i use .Value propertie i can do that, my problem is how can i do this.
You can't really, because the expression is just a value to display in the column - and since it's not a field name, it is therefore unbound. You may need some code in grid's .afterrowcolchange (or in a bound event, that'd be easier than to subclass each grid) which would do the calculation on the current record whenever the underlying fields in this expression change, and replace the value in the u_valhum field. You can do this bindevent() in the form's init - no need to roll through _screen.forms.