Update Stock Sold

Update Stock Sold

Hi

I am sorry to bring this on here but I am really stuck.
So I have a form that lists all our products we sell with a field for Purchased Stock and Sold Stock.

I have another form for Purchase of Products, which when filled out, updates the Purchased Stock Field, this works

I have 2 forms for selling,
Form B - 1 Looks up product (This is a hidden form)

2nd one for Actual selling, will have client name address details and a subform to Form B to select product being sold and quantity multiple products can be sold at a time, 

What I am struggling with is, to update the Sold field when product is sold

I have a function with following code

void Sold.UpdateSold(int id)
{
transactions = Sale[Products.ID == id];
Soldcount = 0;
for each  transactionToSum in transactions
{
Soldcount = Soldcount + transactionToSum.Qty;
}
UpdateSold = Products[ID == id];
UpdateSold.Sold=Soldcount;
}

Then a Form workflow, when New Sale form is subbmitted

for each  rec in input.Product_Sale
{
thisapp.Sold.UpdateSold(input.Product_Sale.ID);
}

when I run the form and submit I get following error

Error details:
 Error in executing On Create / Edit - On Success script
 Error in executing thisapp.Sold.UpdateSold function. Line:(3)
 Unable to update the value to UpdateSold.Sold. Line:(10)
 'UpdateSold' has no matching records. Unable to update the value UpdateSold.Sold. Line:(10)

Please can someone help me:(

Thank you