Fetch record Issue

Fetch record Issue

Having trouble fetching a record.

In Short:

I have 

Form 1 - Material Type
      Field - Material_Type
      Field - Material_Type_Code

Form 2 - Material 0.2
      Field - Material_Type - (Look up to form 1)
      In-Line Sub Form - Material in 
      in-Line Sub Form - Material out
      Field - Available - Calc of ((Material in*n) - (Material out*n))
     
Form 3 - Order Tickets
      Field - Material_Type (Look up to Form 1)
      Field - Available - (Material available from form 2)
      some calculation fields to see how much material the order will use 
      Field Remaining - Calculation of (material used - Available)

My Issue is on Form 3 i can not get the "Available" Field to populate. 

the code im trying to use to fetch the info is:

 x  =  form 2   [ID == input.Material_Type];
alert(x);
z = x.Available;
alert(z);

The alert X box brings up every id number from that form not just the one selected in the look up field, causing the z variable to be null .....am i just missing a step ?

Mike