Select based on other field value

Dear Gurus

I created master/detail forms for returned goods, in details form I have field “productid” (using select type)
What I need, the “productid” selection only show items based on value in field “orderid” which was placed in master form

How can I achieve that ?

thank you

then your select must be:
select **** from *** where productid IN(’{field_orderid}’)

okay, sounds reasonable,
just one question, {field_orderid} is the field placed in master form ,… can details form recognize value field from master ? can they communicate ?

thanks

hi gurus, this is what i put inside SQL inside fproductid field :

select fproductid,fnamabrg from tbbarang inner join tbpesandet on tbpesandet.fkodebrg=tbbarang.fproductid where tbpesandet.fnopesan = ‘. {fnopesan} .’

while {fnopesan} is field placed in Master form, How can I get the field value from master form to be used in detail form. ???

really need help

thanks