Here is what your code might look like to loop through a subform's recordset:
Code:
Private Sub Command15_Click()
On Error GoTo ErrHandler
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim qry As String
Dim total_stock as Double
Dim allocated_stock as double
Set db = CurrentDb
Set rst = Me.OrderProduct.Form.RecordsetClone
If Not (rst.BOF And rst.EOF) Then
rst.MoveFirst
Do While Not rst.EOF
'----------------------------------
'BEGIN CODE TO EXECUTE UPDATE QUERY
total_stock = 1 'change these to how ever you're calculating these fields. refere to fields in the subform's recordset like rst![field_name]
allocated_stock = 1
qry = "UPDATE ProductTbl SET TotalStock = " & total_stock & ", AllocatedStock = " & allocated_stock & " WHERE ProductId = " & rst!ProductId
db.Execute qry, dbFailOnError
'END CODE TO EXECUTE UPDATE QUERY
'----------------------------------
rst.MoveNext
Loop
End If
rst.Close
ExitHandler:
Set rst = Nothing
Set db = Nothing
Exit Sub
ErrHandler:
MsgBox Err.Description, , "Error #" & Err.Number
Resume ExitHandler
End Sub