SUM used on filtered records (1 Viewer)

Mantispony

Registered User.
Local time
Today, 17:56
Joined
Mar 31, 2011
Messages
15
Hi, I thought I knew enough about Access until I took a look in here, lol.

(Feel free to move or delete this thread if appropriate)

My challenge is this:

I've got a list of customers and their sales values, as below:
custID | custName | custGroup | custValue

The custGroup field is where we keep track of who handles that customer regularly. I'd like an additional field CustTotalValue to display the sum of that person's group's sales.

Bottom line: When I filter on group 3, I'd like CustTotalValue to display the sum of custValue for group 3.

I'm not VBA fluent, so if this solution requires VBA; please pretend you're explaining it to a 3-year-old ;)

Many thanks
 

Trevor G

Registered User.
Local time
Today, 16:56
Joined
Oct 1, 2009
Messages
2,341
Have you looked at using the DSUM via the expression builder.

DSum («expr», «domain», «criteria»)

Suggestion create a form from the table, then add an extra Texbox to the form, and then use the DSUM function in the extra text box, you can then look to do something like filter the form to show the person group sales.
 

Mantispony

Registered User.
Local time
Today, 17:56
Joined
Mar 31, 2011
Messages
15
..ok so I've got this: DSum (+, TOTAAL2011, «criteria») but I don't know what to put for the criteria. (and I'm not sure about the + either lol, I only have a VERY basic understanding of functions)

"TOTAAL2011" is the field where the total sales for 2011 are stored. Does the "group" field go in criteria?

Thanks ever so much!
 

Apolo13

New member
Local time
Today, 19:56
Joined
Jun 17, 2014
Messages
2
Can I see the YouTube's clip?
I clicked on the link, but it not work... :confused:
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 11:56
Joined
Feb 19, 2002
Messages
43,265
Assuming this is a report or a form, create a new control. The ControlSource will be something like:

=dSum("custValue", "yourtablename", " custGroup = " & custGroup)

Change "yourtablename" to the name of your table. The other field names should be ok. If the group is a string, you will need to use the following instead:

=dSum("custValue", "yourtablename", " custGroup = '" & custGroup) & "'"
 

Users who are viewing this thread

Top Bottom