I have two queries created using Builder in Design View. The only difference between the two queries is that one evaluates an expression and returns records where the value of the expression is <11 and the other when the values are >10. In SQL view the two queries are identical except for the <11/>10. In design view the column with the expression that's evaluated for the where clause has "Expr1:" in front of the expression for the query that won't save and doesn't have anything in front of it in the query that does save.
I've tried deleting the "Expr1:" but Design view just reinserts it.
The SQL View for the one that saves is:
Code:
INSERT INTO MonthlyMetric ( MetricYear, [Metric Month],MetricType, MetricEndDate, Metric, MetricValue )
SELECT IIf(DatePart("q",[Forms]![MonthlyAppend]![End Date])=4,DatePart("yyyy",[Forms]![Monthly Append]![EndDate])+1,DatePart("yyyy",[Forms]![Monthly Append]![End Date])) AS[Metric Year], Month([Forms]![Monthly Append]![End Date]) AS [Metric Month],"Count of CRs Over Decision Goal by Priority" AS [Metric Type], [Forms]![MonthlyAppend]![End Date] AS Expr4, [Change Request Intake].[Priority Level],Count([Change Request Intake].[Change Request #]) AS [CountOfChange Request #]
FROM [Change Request Intake]
WHERE ((([Change RequestIntake].Decision)<>"Cancelled") AND (([Change Request Intake].[ForAdmin Only]) Is Null) AND (([Change Request Intake].[Date Ready ForAssessment])<[Forms]![Monthly Append]![End Date]) AND (([Change RequestIntake].[Decision Final Date]) Is Null Or ([Change Request Intake].[DecisionFinal Date])>DateAdd('m',-1,[Forms]![Monthly Append]![End Date])) AND((IIf(IsNull([Change Request Intake]![Decision FinalDate]),DateDiff('d',[Change Request Intake]![Date Ready ForAssessment],[Forms]![Monthly Append]![End Date]),DateDiff('d',[Change RequestIntake]![Date Ready For Assessment],[Change Request Intake]![Decision FinalDate])))>10))
GROUP BY [Change Request Intake].[Priority Level]
HAVING ((([Change Request Intake].[PriorityLevel])="Emergency" Or ([Change Request Intake].[PriorityLevel])="Level 1"));
The one that won't save is:
Code:
INSERT INTO MonthlyMetric ( MetricYear, [Metric Month],MetricType, MetricEndDate, Metric, MetricValue )
SELECT IIf(DatePart("q",[Forms]![MonthlyAppend]![End Date])=4,DatePart("yyyy",[Forms]![Monthly Append]![EndDate])+1,DatePart("yyyy",[Forms]![Monthly Append]![End Date])) AS[Metric Year], Month([Forms]![Monthly Append]![End Date]) AS [Metric Month], "Countof CRs Under Decision Goal by Priority" AS [Metric Type], [Forms]![MonthlyAppend]![End Date] AS Expr4, [Change Request Intake].[Priority Level],Count([Change Request Intake].[Change Request #]) AS [CountOfChange Request #]
FROM [Change Request Intake]
WHERE ((([Change RequestIntake].Decision)<>"Cancelled") AND (([Change RequestIntake].[For Admin Only]) Is Null) AND (([Change Request Intake].[Date ReadyFor Assessment])<[Forms]![Monthly Append]![End Date]) AND (([Change RequestIntake].[Decision Final Date]) Is Null Or ([Change Request Intake].[DecisionFinal Date])>DateAdd('m',-1,[Forms]![Monthly Append]![End Date])) AND((IIf(IsNull([Change Request Intake]![Decision FinalDate]),DateDiff('d',[Change Request Intake]![Date Ready ForAssessment],[Forms]![Monthly Append]![End Date]),DateDiff('d',[Change RequestIntake]![Date Ready For Assessment],[Change Request Intake]![Decision FinalDate])))<11))
GROUP BY [Change Request Intake].[Priority Level]
HAVING ((([Change Request Intake].[PriorityLevel])="Emergency" Or ([Change Request Intake].[PriorityLevel])="Level 1"));
Both queries run but I need to save the one that doesn't save.
Any suggestions?
Thanks