SUM has a scope clause, which can be ALL. Since you can leave out spaces the syntax [tt]SUM ALL(field) TO textbox[/tt] actually works, but not as you think.
First, it'll put the sum into a variable called textbox, not into a textbox. A textbox is an objecct and can't be set to some value, any object, whether a control or anything else, is created and can be released, but never can be set. The objects
properties can be set. You can SUM to a numeric object property, eg [tt]SUM ALL field TO thisform.text1.value[/tt].
You see, ALL is not a function, and your field is not a parameter, ALL is a scope.
help said:
Scope
Specifies a range of records to include in the total...
...The default scope for SUM is ALL records.
That means, if you
don't specify a scope, ALL records are summed anyway.
If using SUM in sql you have parenthesis like [tt]SUM(field)[/tt], but not with the SUM command.
Per example code the SUM command can even do several sums, as in SUM field1,field2 TO variable1,variable2. In SQL you'd need SUM(field1) AS sumfield1, SUM(field2) AS sumfield2.
Besides all that [tt]SUM field TO thisform.text1.value[/tt] would be ok, if done within the form code, but might still not be sufficient for your needs, ie it doesn't update automatically when data changes. If you want a sum display on your form you better set the controlsource of the sum textbox to a function returning the sum, or better yet to a form method. Then any refresh of the form or control will recompute and show the sum. A sum only is static, if the data is static, therefore setting a control.value just once will only be sufficient in that case.
Bye, Olaf.