Here's the SQL statement:
Code:
SELECT a.GENERATION, b.failcode, b.failcode2, Count(*) AS Amount, Count(*)/(SELECT Count(*) FROM LTO_FR_LTO_PRODUCT_DESCRIPTIONS AS a INNER JOIN LTO_FR_TRIAGEA AS b ON a.PN=b.PN WHERE (((b.DT)>=[Forms]![QP]![txtTaFromDate] And (b.DT)<DateSerial(Year([Forms]![QP]![txtTaToDate]),Month([Forms]![QP]![txtTaToDate]),Day([Forms]![QP]![txtTaToDate]))+1) And (a.generation)=[Forms]![QP]![cmbTaGen])AND ((a.FORM_FACTOR)=IIf([Forms]![QP]![Height]=1,"HH",IIf([Forms]![QP]![Height]=2,"FH",[a.FORM_FACTOR])))) AS Percentage, a.FORM_FACTOR
FROM LTO_FR_LTO_PRODUCT_DESCRIPTIONS AS a INNER JOIN LTO_FR_TRIAGEA AS b ON a.PN=b.PN
WHERE (((b.DT)>=Forms!QP!txtTaFromDate And (b.DT)<DateSerial(Year(Forms!QP!txtTaToDate),Month(Forms!QP!txtTaToDate),Day(Forms!QP!txtTaToDate))+1) And ((a.generation)=Forms!QP!cmbTaGen) And ((a.FORM_FACTOR)=IIf(Forms!QP!Height=1,"HH",IIf(Forms!QP!Height=2,"FH",[a.FORM_FACTOR]))))
GROUP BY a.GENERATION, b.failcode, b.failcode2, a.FORM_FACTOR
ORDER BY Count(*) DESC , a.FORM_FACTOR DESC;
As you can see I extract some values from the form QP. However, If I define the values explicitly (w/o using the form) the query runs faster.
Orlando