Filling a field with On User Input

Filling a field with On User Input

I'm having a bit of trouble getting one field to fill in based on the input of another field. Here are the details:

I have one form called Part_Types. In that form there are only two fields: Part_Type (single line) & Part_ID_Number (decimal). The Part_Types form is completely populated with all of its needed data.

The second form is called Parts. In the Parts form I have, among others, a Type field, which is a drop-down list based on on the Part_Type field from the Part_Types form and a Part_ID field (decimal) that I want to have automatically populated with the Part_ID_Number (Part_Types form) from the corresponding Type that was selected.

I thought I had it figured out but it's not working. On the Type field drop-down I have an "On User Input" script that says:

   
  1. temp = Part_Types[Part_Type == input.Type]; temp.Part_ID_Number = input.Part_ID;


Instead of filling in the Part_ID field on the Parts form with the Part_ID_Number from the Part_Types form, it seems to leave the one blank and erase the data in the Part_ID_Number field.

Thanks for any help you can offer,
Mike