Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Optional Parameters in a Query using a Form

Status
Not open for further replies.

Jacqui3

MIS
May 8, 2002
13
0
0
ZA
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,"*")));
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top