I think I know how to change the code I sent earlier to do this. The following code should do the calculation you need
Dim ds As DAO.Database
Dim rs As DAO.Recordset
Set db = daoApp.OpenDatabase _
("Your_database_location_and_name"

Set rs = db.OpenRecordset("Table_name"

i=0
rs.MoveFirst
rs.Fields(1)=i 'Sets your col1 in the first row as 0
j=rs.Fields(2) 'Gives j the value of col2
k=rs.Fields(3) 'Gives k the value of col3
l=i+j-k 'The value of l is the one for col4
rs.Fields(4)=l 'Sets the value for col4
i=l 'Sets i equal to the value in col4
rs.MoveNext
Do While Not rs.EOF
f=rs.Fields(0) 'Gets current value of entry of col0
rs.MovePrevious
g=Fields(0) 'Gets value of previous entry
rs.MoveNext
If f<>g Then
i=0
j=rs.Fields(2)
k=rs.Fields(3)
l=i+j-k
rs.Fields(4)=l
Else
i=l
rs.Fields(1)=i
j=rs.Fields(2)
k=rs.Fields(3)
l=i+j-k
rs.Fields(4)=l
End If
rs.MoveNext
Loop
I think this should solve the problem. Let me know if it does not and I will have another look.
dyarwood