Totals pt 2

C

Calvin

I am having trouble I have making a calculation I was told by my previous
question you cannot add controls but can you?

I have two fields that are being calculated contract amount * # of years
customers to equal their total estimated worth. these are both fields. This
gives me their individual worth This works fine across the report it's just I
want to know my total in all worth of customers. I want to add all of them
but I am having extremely difficult times trying to make this happen.
 
M

Marshall Barton

Calvin said:
I am having trouble I have making a calculation I was told by my previous
question you cannot add controls but can you?

I have two fields that are being calculated contract amount * # of years
customers to equal their total estimated worth. these are both fields. This
gives me their individual worth This works fine across the report it's just I
want to know my total in all worth of customers. I want to add all of them
but I am having extremely difficult times trying to make this happen.


You can not use the Sum function on controls, period.
However, your calculation is simple enough to use the Sum
function in a report footer text box:
=Sum([contract amount] * [# of years])

If your calculation were too complex for that, then you
could use the RunningSum property on a detail section text
box that calculates the values you want to total. Another
way could be to create a public function that performs the
calculation and sum that. For example,

Public Function ContractValue(amt, years)
ContractValue = [contract amount] * [# of years]
End Function

and then use this expression in a report footer text box:
=Sum(ContractValue([contract amount], [# of years]))
 
C

Calvin

Where would this public function go? a blank text box, do I enter it in a
code builder? and then where does the expression go in a blank text box as
well?

Marshall Barton said:
Calvin said:
I am having trouble I have making a calculation I was told by my previous
question you cannot add controls but can you?

I have two fields that are being calculated contract amount * # of years
customers to equal their total estimated worth. these are both fields. This
gives me their individual worth This works fine across the report it's just I
want to know my total in all worth of customers. I want to add all of them
but I am having extremely difficult times trying to make this happen.


You can not use the Sum function on controls, period.
However, your calculation is simple enough to use the Sum
function in a report footer text box:
=Sum([contract amount] * [# of years])

If your calculation were too complex for that, then you
could use the RunningSum property on a detail section text
box that calculates the values you want to total. Another
way could be to create a public function that performs the
calculation and sum that. For example,

Public Function ContractValue(amt, years)
ContractValue = [contract amount] * [# of years]
End Function

and then use this expression in a report footer text box:
=Sum(ContractValue([contract amount], [# of years]))
 
M

Marshall Barton

Functions go in a standard module. The call to the function
is as I described in a report footer text box.

Why can't you just use the
=Sum([contract amount] * [# of years])
--
Marsh
MVP [MS Access]

Where would this public function go? a blank text box, do I enter it in a
code builder? and then where does the expression go in a blank text box as
well?

Marshall Barton said:
Calvin said:
I am having trouble I have making a calculation I was told by my previous
question you cannot add controls but can you?

I have two fields that are being calculated contract amount * # of years
customers to equal their total estimated worth. these are both fields. This
gives me their individual worth This works fine across the report it's just I
want to know my total in all worth of customers. I want to add all of them
but I am having extremely difficult times trying to make this happen.


You can not use the Sum function on controls, period.
However, your calculation is simple enough to use the Sum
function in a report footer text box:
=Sum([contract amount] * [# of years])

If your calculation were too complex for that, then you
could use the RunningSum property on a detail section text
box that calculates the values you want to total. Another
way could be to create a public function that performs the
calculation and sum that. For example,

Public Function ContractValue(amt, years)
ContractValue = [contract amount] * [# of years]
End Function

and then use this expression in a report footer text box:
=Sum(ContractValue([contract amount], [# of years]))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top