Store a report's ReportFooter summed total to a table

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Looking for the best way to store a summed field value (e.g., =Sum([field1]))
to a table. When I use a ReportFooter OnFormat event to store the value, it
sometimes tries to store the value multiple times.
 
That would seem to indicate that the footer gets formatted more than once.
What about just writing a query that calculates the same summed figure that
displays on the report and appends a record to the table? Then just run this
query in the report's Close event. Or even just put your current code in the
report's Close event, since that fires only once.
 
Why do you want to store it, if it can change at any time, use a query to
retrieve the Sum, or in code you can use DSum

DSum("[FieldName]","[TableOrQueryName]")

The values in the field that you are creating the sum on can change, but the
sum value won't change until you open the report again.
If you search this discussion group about storing a calculated field, you
will always get the same answer "Don't do it"
 
Thanks for the replies.

1. I know that Best Practices discourage storing calculated values, but the
"design team" has decided to use this approach. (i lost the battle)
2. In addition to being based on fairly sophisticated queries, the report
also contains a lot of fairly complex calculations, and I am trying to avoid
creating a new query to do the calculations. Since the final total in the
report is good, I'll just grab it. (note: the report was done by a
long-gone developer)
3. Sounds like a can use the OnClose event, since it only runs once.


Ofer said:
Why do you want to store it, if it can change at any time, use a query to
retrieve the Sum, or in code you can use DSum

DSum("[FieldName]","[TableOrQueryName]")

The values in the field that you are creating the sum on can change, but the
sum value won't change until you open the report again.
If you search this discussion group about storing a calculated field, you
will always get the same answer "Don't do it"

--
\\// Live Long and Prosper \\//
BS"D


jsccorps said:
Looking for the best way to store a summed field value (e.g., =Sum([field1]))
to a table. When I use a ReportFooter OnFormat event to store the value, it
sometimes tries to store the value multiple times.
 
In that case I would use the close even of the report

--
\\// Live Long and Prosper \\//
BS"D


jsccorps said:
Thanks for the replies.

1. I know that Best Practices discourage storing calculated values, but the
"design team" has decided to use this approach. (i lost the battle)
2. In addition to being based on fairly sophisticated queries, the report
also contains a lot of fairly complex calculations, and I am trying to avoid
creating a new query to do the calculations. Since the final total in the
report is good, I'll just grab it. (note: the report was done by a
long-gone developer)
3. Sounds like a can use the OnClose event, since it only runs once.


Ofer said:
Why do you want to store it, if it can change at any time, use a query to
retrieve the Sum, or in code you can use DSum

DSum("[FieldName]","[TableOrQueryName]")

The values in the field that you are creating the sum on can change, but the
sum value won't change until you open the report again.
If you search this discussion group about storing a calculated field, you
will always get the same answer "Don't do it"

--
\\// Live Long and Prosper \\//
BS"D


jsccorps said:
Looking for the best way to store a summed field value (e.g., =Sum([field1]))
to a table. When I use a ReportFooter OnFormat event to store the value, it
sometimes tries to store the value multiple times.
 
Back
Top