Access Sum not working as control source

Hi

I have an Access Report where the control source "[Invoice Details].[Amount]" works on a control but  "=Nz(Sum([Invoice Details].[Amount]),0)" does not.
It causes an error. This makes no sense to me.

Thanks
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Fabrice LambertFabrice LambertCommented:
Hi,

Is the control bound ?
Did you try with an unbound control and a query ?
0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
Maybe ...
=Sum(Nz( [Invoice Details].[Amount] , 0) )

What is the error ?
0
PatHartmanCommented:
The Sum() and other aggregate functions handle nulls.  You do not need to use Nz() in this situation.
Since Access does not support field names that contain dots, what is
[Invoice Details].[Amount]
referring to?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
Maybe it needs to be:

=Sum([Amount])
0
mbizupCommented:
->>>  works on a control

The aggregate functions (SUM, AVG, etc) do not work on control names.  You need to use the name of the underlying field if it differs from the control name.  Check the control source property of your textbox.

If it is a simple fieldname use this in your aggregate function:
 
SUM (Field1)

Open in new window


For an expression use something like this:
SUM (Field1 + Field2)

Open in new window

0
PatHartmanCommented:
Correct but in that case, you will have to use Nz() if Field1 or Field2 might be null because  because Access performs the addition operation first and that will fail if either field is null event though the sum() handles nulls by ignoring them.

Sum(Nz(Field1,0) + Nz(Field2,0))
0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
As a side note  I was assuming [Amount] is the Field name ....
0
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks for the advice
0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
What was the actual problem ?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.