kogelman
10th July 2003, 11:48
I use a multi-occurence form with about 20 records on it.
Every record has a 'start Kilometerstanding(mileage)' and an 'end Kilometerstanding'

When the 'end Km-standing' changes, I want to write the new value to a separate table inmediatly.
This to check that the 'start Km-standing' of the next record is the same as the 'end Km-standing' of the previous record of that particular truck.

When I try to update the separate table in the 'when.field.changes: ' section, I have to use a commit.transaction(). When I do that the lock of the main table has gone too, so the program can not update the main table.

I hope I have descriped the problem clearly.

Thanx in forward !!!

vahdani
10th July 2003, 12:07
It is bad programming practice to update tables in field sections. What happens when the user changes his/her mind and presses redo button? Believe me this programming style will get you nowhere fast!

You should update any tables only in "main.table.io section" where data is actually written to (or deleted from) the main table.

May the force be with you!

Toni

kogelman
10th July 2003, 12:16
I know that's the concequence of updating fields in the field section, but I don't see anonther solution to program a correct check of the KM-standings.

The problem is that a user can enter a lot of KM-standings in a lot of records before he updates the database.
When he goes to the next record of the same truck (before writing) I have to check if he enters the KM's correctly.

vahdani
10th July 2003, 12:29
Then use something like this

Field.tablexxx.start.milage:
check.input:
if actual.occ > 1 then
do.occ.whithout.update(actual.occ - 1,
get.last.end.milage)
else
get.end.milage.from.main.table()
endif
if tablexxx.start.milage < last.end.milage then
message("xxxxx"
set.input.error("")
endif

function get.last.end.milage()
{
last.end.milage = tablexxx.end.milage
}

function get.last.end.milage.from.table()
{
select max(end.milage):last.end.milage
from table xxxx
where yyyy
}

kogelman
10th July 2003, 12:47
I will try it.

Thank you !!!