yronium Level: Moderator

 Registered: 14-04-2002 Posts: 907
|
Re: Sum using access field property
Hello. You didn't specify if you want to do it by a VB application or directly in Access' Design View. I guess you meant the second, as you spoke about ValidationRule property. But anyway it makes no sense to build a table like that.
A global rule for all computing matters is "Don't do what computer can do itself". In databases theory this rule was extended and developed, resulting in the First, Second and Third Normal Form rules. Without entering the deep of each normal form, an application of the First is: never put in a field a value that can be retrieved or computed by another field. In fact, we don't really need to store the sum, we don't really need a field to store it.
Usually we consider tables the places where we find and watch our data, but in fact it is not so: every time a db have to show some data, it should do it by a query.
Queries, which are sometimes named "Views", don't really show data, but a copy of it. This prevent user for accidental changes on records information. Yes, there are some query types which can execute actions on records, but they need to be explicitly built and launched, so this assumes who does it knows exactly what he's doing.
When you open a query - a view - you can compute the sum you need every time. In this way your sum is always updated, and your data is protected by accidental editing as well. The same concept applies to an Age field: once I filled it, it wouldn't be updated anymore the very next day. A BirthDate field is enough, and I can compute the exact age whenever I need to view it.
So don't try to apply any auto-filling criteria to any field: the only one Access recognizes is the Autonumber field, but no more. Access doesn't implement any way to relate by an aggregation function two fields in the same table, and tables have no events to raise in which you can execute a sum or similar.
And this is correct. You better study for another system.
Hope it helps
____________________________
Real Programmer can count up to 1024 on his fingers
|