Ajust quantities in another form based on subform, on form submission

Ajust quantities in another form based on subform, on form submission

Hello,

I have an Order form with a LineItems subform. The LineItems subform has many lookups that import data from various other forms. I want to deduct the quantity offered in one of those other form, called Offer.

In another application I used the following on form submission, but now it doesn't work, even if I do not have errors in the script :

Note = Offer_ID is a paste of the Offer ID's into the LineItems via a lookup.

for each record in LineItems
{
    RefOffer = Offer[ID = LineItems.Offer_ID];
    RefOffer.Quantity_offered = RefOffer.Quantity_offered - LineItems.Quantity_ordered;
}

What is wrong ?

Sylvain