populate select field based on inventory quantity

Hi I would like to know how should i do it, where inventory quantity passed from grid to form then in the form select field display quantity do not larger than inventory quantity.

Example:

inventory = 9 then in the form select field it will show 1,2,3,4,5,6,7,8,9.

I think you can create a variable global [quantity_inv] and create throuht of a FOR the statement: “SELECT 1,2,3,4,5 FROM mytable” and asign this variable to your field type select for it shows the values.