Updating Feild by itself and code not working on new line on subform

Updating Feild by itself and code not working on new line on subform

Hello,

I created a subform for recording time then I wrote a code like below but this code is working only for 1. row.

When I tried to add new record the code doesn't work.

Also the field isn't updating by itself. I have to insert random time first the it updates itself.

If you help me, I will be grateful.

Thanks




input.TIME_RECORD.Time = 00;
HourStartTime = input.TIME_RECORD.START.getHour();
HourEndTime = input.TIME_RECORD.FINISH.getHour();
MinuteStartTime = input.TIME_RECORD.START.getMinutes();
MinuteEndTime = input.TIME_RECORD.FINISH.getMinutes();
for each  add_new in TIME_RECORD
{
Hour = HourEndTime.tolong() - HourStartTime.tolong();
Min = MinuteEndTime.tolong() - MinuteStartTime.tolong();
if(Min <= -1)
{
Hour = Hour - 1;
Min = MinuteEndTime.tolong() + 60 - MinuteStartTime.tolong();
}
}
input.TIME_RECORD.Time = input.TIME_RECORD.Time.addHour(Hour);
input.TIME_RECORD.Time = input.TIME_RECORD.Time.addMinutes(Min);