Value in a table equal to the sum of other values

James.90

Registered User.
Local time
Today, 03:41
Joined
Nov 14, 2007
Messages
49
Hey.

Is there any way to make a field in a record automatically set it self so it's the sum of other values in the record

http://img412.imageshack.us/img412/1677/helphg9.jpg

That's an example what i want to do except i had to manually type in 25. Is there any way to get that so it does that automatically. I am happy to use forms or macros or anything as long as it occurs straight away after the data is inputted and not have to run something or open something up

Thanks in advance
 
You might try creating a query with something like this :

SELECT Yourtable.Maan, Yourtable.Dins, Yourtable.Woens, Yourtable.Donder, Yourtable.Vrij, Yourtable.Zater, Yourtable.Zon, Nz([Maan]+[Dins]+[Woens]+[Donder]+[Vrij]+[Zater]+[Zon]) AS total
FROM Yourtable;

Note that Maan, Dins, etc are the names of the field you used for Monday, Tuesday, etc. These are numeric fields, hence the Nz function.

Hth
 
Nz([Maan]+[Dins]+[Woens]+[Donder]+[Vrij]+[Zater]+[Zon])

Wouldn't you need to use Nz() on each field rather than using it on the sum of them?

If only one of the above fields is null, wouldn't the whole expression work out to be 0 or #Error#?
 
So how does it work so it runs automatically when i new record is entered into the database.

Because all the data is getting entered via a web page i want to make sure i don't need the database open
 
You shouldn't store calculated values in a record in a table. Calculate them when you you need them for a report or form.

If you store the calculated value you need to make sure you recalculate it every time one of the component values is changed.
 
So how does it work so it runs automatically when i new record is entered into the database.

Because all the data is getting entered via a web page i want to make sure i don't need the database open
If you don't have the database open and you are simply inserting records into a table, then it's not Access that has control, it's your web page. You would need to calculate the total in the web page, and as Rabbie says, there is no need to store this total at all.
 

Users who are viewing this thread

Back
Top Bottom