How do you auto fill a lookup field based on input of previous lookup field?

How do you auto fill a lookup field based on input of previous lookup field?

I'm getting the following error when I try to auto-fill a second lookup field based on the information I entered into the first lookup field:

Error at line number: 2
In Criteria left expression is of type STRING and right expression is of type BIGINTLIST and the operator == is not valid

The data I'm trying to fetch is in the Commodity Codes form.  The form I'm trying to input the data into is the Contract Summary form.

Commodity Codes (form fields)
Commodity_Codes1 (Number)
Goods_Services_Category1 (Single line)

Contract Summary (form fields)
Commodity_Codes2 (Lookup)
Goods_Services_Category2 (Lookup)

Here's the code I used in the Goods_Services_Category2 field:

// fetch records from Commodity_Codes form, stored in the variable "temp"
temp = Commodity_Codes [Goods_Services_Category1 == input.Goods_Services_Category2];
// put data in fields
input.Commodity_Codes2 = temp.Commodity_Codes1;

I'm trying to have the Commodity_Codes2 field auto-filled once the Goods_Services_Category2 field is filled in.  And I'd like it to go both ways if possible - that either field will auto-fill based on the input of the other, but I'll settle for just having the Commodity_Codes2 field auto-filled for now based on what is entered into the Goods_Services_Category2 field.

Any help would be much appreciated!  Mahalo!