What is wrong with this code?

What is wrong with this code?

I have a form Month_Status, with fields (among others) MD_Serial, Inv_Amt, Order_Amt.
I want to update form Temp_Inv for correspomding MD_Serial.

I have tried:
for each y in Temp_Inv
{
   if(Month_Status[ID == y.MD_Serial].count() > 0
   {
      x = Month_Status[ID == y.MD_Serial]
      y.Last_Inv = x.Inv_Amt
      y.On_Order_Qty = x.Order_Amt
   }
}
and
for each y in Temp_Inv
{
    if([Month_Status.MD_Serial == y.MD_Serial].count() > 0
   {
       x = [Month_Status.MD_Serial == y.MD_Serial];
      y.Last_Inv = x.Inv_Amt;
      y.On_Order_Qty = x.Order_Amt;
   }
}
But I keep getting error messages

What is wrong?

Alex Scott