How to calculate the accumulate value of the current field

djungna

Registered User.
Local time
Today, 18:10
Joined
Dec 28, 2004
Messages
19
If I have the field name as below:

Oil quantity
Accumulate Oil quantity
Date
Recordnumber


I want to get value of "Accumulate oil quantity" of current record to be equal to sum of "Oil quantity" from first record till the current record:

Let say
after I input "oil quantity" in the record # 1 ,2 & 3
The "Accumulate oil quantity" of record value show below:

"Accumulate oil quantity" of record#1 = "Oil quantity" of record#1
"Accumulate oil quantity" of record#2 = "Oil quantity" of record#1 + "Oil quantity" of record#2
"Accumulate oil quantity" of record#3 = "Oil quantity" of record#1 + "Oil quantity" of record#2+"Oil quantity" of record#3

Anyone know , please help
Thank you so much
 
I wouldnt store a calulated field in the database, its much better to calculate the figure when you need it in case you change any earlier figures.

Try putting an unbound text box on your form and in the current event for the form put

txtMyTextBox = DSum("[Oil quantity]","tblOil","RecordNumber < = " & RecordNumber)

This assumes tblOil is your table name and your record number field is holding some sort of sequential numbering. If not, you may be better using an ID field as an Autonumber field instead.
 

Users who are viewing this thread

Back
Top Bottom