That's because you have the inner m.divi = curbilldata.divi AND NOT EOF() loop, which moves to the last record without doing anything.
Use curbilldata
Use curbilldata again as dummy
Scan
m.divi = curbilldata.divi
Select dummy
SUM val(tot_t) to m.r for dummy.divi=m.divi
m.qa=(VAL(curbilldata.tot_t))/(VAL(curbilldata.tot_tot))
? m.qa
select curbilldata
replace tot_tot WITH str(m.r/2,10,2)
Endscan
Use in dummy
Brow
But why in he** do you use character fields for numeric values??? Use numeric, currency or integer
ALWAYS, always, ALWAYS for numeric values!!!!!!!!
>hi,
>i try many tims,
>if i remove ,for m.divi = curbilldata.divi
>i get result for every divi as
>
>divi tot_tot
>----- -------
>a
>a
>a
>a 12345
>b
>b
>b 3214
>.
>.
>
>--------------
>but i need it as
>divi tot_tot
>----- -------
>a 12345
>a 12345
>a 12345
>a 12345
>b 3214
>b 3214
>b 3214
>c
>c
>.
>.
>
>thanks.
>
>>Sorry, I did not notice that you used VFP8, the update syntax I showed you was introduced in VFP9. For VFP8 you should use a Scan-Endscan loop.
>>
>>But I really don't understand why you have the inner m.divi = curbilldata.divi AND NOT EOF() loop, is it to find the last record in a group?
>>
>>>hello ,
>>>i try i get error messag
>>>function name is missing
>>>thanks.
>>>>You should learn SQL, you will save a looot of time! Something like this will replace your whole little program:
>>>>Update curbilldata set tot_tot=(Select sum(master.tot_t/2) from curbilldata master where master.divi=curbilldata.divi)
>>>>
>>>>NB! Note that this line may not do the work without modifications, but is should be a very good start!
>>>>