Sum() Control Source for Text Box

  • Thread starter Thread starter Bill M
  • Start date Start date
B

Bill M

Why don't you simply add a column to the query
Total:=[1]+[2]+[3]+[4]+[5]+[6]+[7]+[8]
and then on the text box enter =Sum([Total])
assuming you want the total for the group of records
place the text box in a group header and it will total for
an entire group of records.
 
Yes, I think I'll do that.
I also have an AVG column which is supposed to average the
returned values. But it is averaging based on the number
of rows before the summing instead of after the summing.
Is there any way around that? I guess I could do that in
the report instead of the query.

-----Original Message-----
Why don't you simply add a column to the query
Total:=[1]+[2]+[3]+[4]+[5]+[6]+[7]+[8]
and then on the text box enter =Sum([Total])
assuming you want the total for the group of records
place the text box in a group header and it will total for
an entire group of records.
-----Original Message-----
I have a query that returns columns called 1, 2, 3, 4, 5,
6, 7 and 8.

I want to populate a text box with the sum of these values.
I tried the following =Sum([1],[2],[3],[4],[5],[6],[7], [8])
When I do this I get an error saying "The expression you
entered has a function containing the wrong number of
arguments". I looked up the syntax for Sum() and I cannot
find anything wrong. HELP!
.
.
 
Sum() and Avg() do not work the way they do in Excel where you list the
values to be summes or averaged. In Access Sum() and Avg() are specific
functions that returns the sum or average for a specific field of every row
in the table. These functions only expect one value to be passed to it, the
field that the function will work on. Sum([a],) will always cause an
error since you are passing 2 values. Use Bill's suggestion of totaling the
fields manually then performing the Sum() or Avg() on that new field. If
you are doing this in a query you can write the expressions Total:
sum([a]++[c]+etc...) and Average: avg([a]++[c]+etc...). This will
perform the addition of [a], , [c], etc... then get the sum adn average
of this total for every field.

Kelvin

Rebecca said:
Yes, I think I'll do that.
I also have an AVG column which is supposed to average the
returned values. But it is averaging based on the number
of rows before the summing instead of after the summing.
Is there any way around that? I guess I could do that in
the report instead of the query.

-----Original Message-----
Why don't you simply add a column to the query
Total:=[1]+[2]+[3]+[4]+[5]+[6]+[7]+[8]
and then on the text box enter =Sum([Total])
assuming you want the total for the group of records
place the text box in a group header and it will total for
an entire group of records.
-----Original Message-----
I have a query that returns columns called 1, 2, 3, 4, 5,
6, 7 and 8.

I want to populate a text box with the sum of these values.
I tried the following =Sum([1],[2],[3],[4],[5],[6],[7], [8])
When I do this I get an error saying "The expression you
entered has a function containing the wrong number of
arguments". I looked up the syntax for Sum() and I cannot
find anything wrong. HELP!
.
.
 
Back
Top