Hi,
I have a MS Access form which calls a Query - the user can select whether or not to enter a date range. The query works when a date range is input BUT if no range is selected I want the query to return all the rows, including the nulls dates.
Here is my SQL - I have bolded the date range bit:
SELECT Project.ProjectCode, Project.WorkAuthWBSDescription, Project.CSCProjectManager, Project.PCRCode, PCRtbl.PCRDescription, Project.ProjectStartDate, Project.ProjectEndDate, Project.EstimatedPersonDays, Project.EstimatedElapsedDays, Project.Completed, etes.TotalHoursPerWeek
FROM (PCRtbl RIGHT JOIN Project ON PCRtbl.PCRcode = Project.PCRCode) INNER JOIN etes ON Project.WBScode = etes.WBSCode
WHERE (((Project.ProjectCode) Like IIf([Forms]![RptProjectVariance]![txtProject] Is Null,"*",[Forms]![RptProjectVariance]![txtProject])) AND ((Project.ProjectStartDate) Between IIf([Forms]![RptProjectVariance]![txtPjStartDateFrom] Is Null,#1/1/1900#,[Forms]![RptProjectVariance]![txtPjStartDateFrom]) And IIf([Forms]![RptProjectVariance]![txtPjStartDateTo] Is Null,#1/1/2100#,[Forms]![RptProjectVariance]![txtPjStartDateTo])) AND ((Project.Completed) Like IIf([Forms]![RptProjectVariance]![txtIncludeCompletedProjects]=No,No,"*"
));
I have a MS Access form which calls a Query - the user can select whether or not to enter a date range. The query works when a date range is input BUT if no range is selected I want the query to return all the rows, including the nulls dates.
Here is my SQL - I have bolded the date range bit:
SELECT Project.ProjectCode, Project.WorkAuthWBSDescription, Project.CSCProjectManager, Project.PCRCode, PCRtbl.PCRDescription, Project.ProjectStartDate, Project.ProjectEndDate, Project.EstimatedPersonDays, Project.EstimatedElapsedDays, Project.Completed, etes.TotalHoursPerWeek
FROM (PCRtbl RIGHT JOIN Project ON PCRtbl.PCRcode = Project.PCRCode) INNER JOIN etes ON Project.WBScode = etes.WBSCode
WHERE (((Project.ProjectCode) Like IIf([Forms]![RptProjectVariance]![txtProject] Is Null,"*",[Forms]![RptProjectVariance]![txtProject])) AND ((Project.ProjectStartDate) Between IIf([Forms]![RptProjectVariance]![txtPjStartDateFrom] Is Null,#1/1/1900#,[Forms]![RptProjectVariance]![txtPjStartDateFrom]) And IIf([Forms]![RptProjectVariance]![txtPjStartDateTo] Is Null,#1/1/2100#,[Forms]![RptProjectVariance]![txtPjStartDateTo])) AND ((Project.Completed) Like IIf([Forms]![RptProjectVariance]![txtIncludeCompletedProjects]=No,No,"*"