here is my selection formula:
{qth.qtnum} = {@QuoteSelection} (this is a parameter i pass after getting a prompt from the user)
this is sql query
SELECT
qtt.`qtlin`,
udtl.`lndesc`, udtl.`udtqtllin`, udtl.`lninfo`,
qtk.`qtlin`,
qth.`ccode`, qth.`csnam`, qth.`plant`, qth.`qtalt`, qth.`qtnum`, qth.`sale1`,
qtl.`qtlin`,
plt.`pcode`, plt.`pdesc`,
cus.`ccode`, cus.`cname`,
udth.`qtnmb`,
srt.`scode`, srt.`sname`
FROM
((((qth LEFT JOIN cus ON qth.ccode = cus.ccode) INNER JOIN srt ON qth.sale1 = srt.scode) LEFT JOIN plt ON qth.plant = plt.pcode) INNER JOIN udth ON qth.qtnum = udth.qtnmb) INNER JOIN (((udtl INNER JOIN qtk ON udtl.qtlkey = qtk.qtlky) INNER JOIN qtl ON qtk.qtlin = qtl.qtlin) INNER JOIN qtt ON (qtl.qtlky = qtt.qtlky) AND (qtk.qtlky = qtt.qtlky)) ON qth.qtnum = left(udtl.udtqtllin,5)