Sum formula within Access (1 Viewer)

Rania01

Member
Local time
Today, 17:15
Joined
Oct 9, 2021
Messages
59
Dear All,

Who can help me with a formula within Access?

Sum all [Bedrag] from [btw Code] ==> BTW Code 1
Sum all [Bedrag] from [btw Code] ==> BTW Code2

Thank you in advanced.

I use formula for the totaal
=[Q_verkooporder_regel Subformulier].[Form]![Totaal bedrag]

Thank you in advance
 

Attachments

  • P4.jpg
    P4.jpg
    143.4 KB · Views: 97

theDBguy

I’m here to help
Staff member
Local time
Today, 08:15
Joined
Oct 29, 2018
Messages
21,468
Hi. Welcome to AWF!

Not sure what your setup looks like, but have you tried creating a Totals query or using the DSum() function?
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 11:15
Joined
Feb 19, 2002
Messages
43,264
Instead of hardcoding the controls as you have, create a totals query that groups by the code field and sums the amount. Using this method means you won't need to modify the form if you add other codes. the sum/group will automatically happen for all unique values of the code field.
 

mike60smart

Registered User.
Local time
Today, 16:15
Joined
Aug 6, 2017
Messages
1,904
Dear All,

Who can help me with a formula within Access?

Sum all [Bedrag] from [btw Code] ==> BTW Code 1
Sum all [Bedrag] from [btw Code] ==> BTW Code2

Thank you in advanced.

I use formula for the totaal
=[Q_verkooporder_regel Subformulier].[Form]![Totaal bedrag]

Thank you in advance
Try a Sum If in the Subform Footer as follows:-

=Sum(IIf([BTW Code]=1,[Bedrag],0))
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 11:15
Joined
Feb 19, 2002
Messages
43,264
As I said, hard coding values like this forces you to modify forms, etc whenever you have new values. If there is a solution that does NOT require hard coding, even if you think that you will never, ever have to add a new code, use the generalized solution. Think of it as defensive programming. You'll look like a genious next month when they want to add new codes and you don't need to modify anything.
 

Users who are viewing this thread

Top Bottom