Solved How to SUM value in subform via VBA code?

yunhsuan

Member
Local time
Today, 07:54
Joined
Sep 10, 2021
Messages
54
Hello~
I use SUM() to calculate value in subform on main Access Form by control data source (Below is "Test" file).
But the value would become unchangeable. So I want to calculate value by using VBA code.
I have tried to use DSum fn, but I failed. Maybe I used the wrong code.
Can any one tell me how to write the code?

Also, can SUM fn skip Null and properly calculate value?
 

Attachments

Aggregate functions ignore Null and only include records where field has data.

I hope you use better naming convention in real database. For starters, don't use spaces.

These work:
=[Table2]![Tax excluded]
=[Table2]![Taxes]
=[Table2]![Tax included]
 
These work:
=[Table2]![Tax excluded]
=[Table2]![Taxes]
=[Table2]![Tax included]
Isn't that interesting. Seems like the original version should be the one that works. Any idea why? Seems like yet another anomaly.
 
June7 provided the solution. It was a reference style issue.
 
Thanks for suggestions! The problem was resolved successfully.
 

Users who are viewing this thread

Back
Top Bottom