I am trying to use an IIF in a query.
I have a form where the use enters in date ranges.
date1 and date2
I want to do a check in the query to see if the first date was null and if so run the query without any date range in the criteria.
the qry worked find before I add in the date ranger.
I have a form where the use enters in date ranges.
date1 and date2
I want to do a check in the query to see if the first date was null and if so run the query without any date range in the criteria.
the qry worked find before I add in the date ranger.
Code:
SELECT PCN.Status_flag, PCN.purpose, PCN.Approval_date, PCN.[PCN_#], PCN.job_title, Cost_Center.location, PCN.cost_center, PCN.Comments, PCN.Hiring_Mgr, PCN.created_date, PCN.Replaced, PCN.Salary_range, PCN.Executive_approved_date, PCN.Reapproved_Date, PCN.Job_description, PCN.Position_Requirements, PCN.position_type, PCN.compensation_type, PCN.emp_name, PCN.Filled_by, PCN.How_filled, PCN.user_name, PCN.start_date, PCN.Expiration_Date, PCN.Status_memo
FROM PCN INNER JOIN Cost_Center ON PCN.cost_center = Cost_Center.number
WHERE (((PCN.Status_flag)=[forms]![frm_rpt_type]![cbo_status].[value]) AND ((PCN.purpose)=[forms]![frm_rpt_type]![cbo_purpose].[value]) AND ((PCN.Approval_date)=IIf(Not (PCN.Approval_date)=IsNull([forms]![frm_rpt_type]![date1].[value]),(PCN.Approval_date) Between [forms]![frm_rpt_type]![date1].[value] And [forms]![frm_rpt_type]![date2].[value]," ")));