Flexible Criteria Search redux
This action page to query mutiple drop-down selection only works with 2 choices- when a third is introduced, it ignores it:
<cfquery name="search_flexible_criteria" datasource="#Request.BaseDSN#">
SELECT
mo.order_ID,
mo.order_number,
mo.order_property_type_ID,
mo.order_order_type_ID,
mo.order_report_type_ID,
mo.order_client_ID,
mo.order_appraiser_ID,
mo.order_status_ID,
mo.order_rush_status_ID,
mo.order_property_street,
mo.order_property_city,
mo.order_create_date,
ls.order_status_ID,
ls.order_status,
lc.client_ID,
lc.client_company,
la.appraiser_ID,
la.appraiser_fname,
la.appraiser_lname,
lo.order_type_ID,
lo.order_type,
lp.property_type_ID,
lp.property_type,
lr.report_type_ID,
lr.report_type,
lrs.rush_status_ID,
lrs.rush_status
FROM main_orders mo
LEFT JOIN lookup_order_status ls
ON mo.order_status_ID = ls.order_status_ID
LEFT JOIN lookup_clients lc
ON mo.order_client_ID = lc.client_ID
LEFT JOIN lookup_appraisers la
ON mo.order_appraiser_ID = la.appraiser_ID
LEFT JOIN lookup_order_type lo
ON mo.order_order_type_ID = lo.order_type_ID
LEFT JOIN lookup_property_type lp
ON mo.order_property_type_ID = lp.property_type_ID
LEFT JOIN lookup_report_type lr
ON mo.order_report_type_ID = lr.report_type_ID
LEFT JOIN lookup_rush_status lrs
ON mo.order_rush_status_ID = lrs.rush_status_ID
WHERE 1 = 1
<cfif StructKeyExists(Form, "StartDate") AND StructKeyExists(Form, "EndDate") AND form.StartDate IS NOT "" AND form.EndDate IS NOT "">
AND (order_create_date BETWEEN #CreateODBCDate(FORM.StartDate)# AND #CreateODBCDate(FORM.EndDate)#)</cfif>
<cfif StructKeyExists(Form, "order_client_ID") AND Form.order_client_ID NEQ 0>
AND client_ID = #Form.order_client_ID# </cfif>
<cfif StructKeyExists(Form, "order_appraiser_ID") AND Form.order_appraiser_ID NEQ 0>
AND appraiser_ID = #Form.order_appraiser_ID#</cfif>
<cfif StructKeyExists(Form, "order_status_ID") AND Form.order_status_ID NEQ 0>
AND mo.order_status_ID = #Form.order_status_ID#</cfif>
<cfif StructKeyExists(Form, "order_rush_status_ID") AND Form.order_rush_status_ID NEQ 0>
AND order_rush_status_ID = #Form.order_rush_status_ID#</cfif>
ORDER BY order_create_date DESC
</cfquery>
Thanks to Carl for getting it this far- hair-pulling, hopefully, will stop soon.
Thank you for taking the time to read this.
Norman
