Chintsapete
Registered User.
- Local time
- Tomorrow, 01:31
- Joined
- Jun 15, 2012
- Messages
- 137
Hi
I can't figure out why the first code is working and after adding a few lines it gives me a syntax error. It highlights the AS ETI. I usually work on the query grid, but I read somewhere there is a limit to the length of expression. So I ended up editing the expression in SQL view, but somehow doesn't work.
Working before editing:
Not working after adding lines:
Thanks for any help
Pete
I can't figure out why the first code is working and after adding a few lines it gives me a syntax error. It highlights the AS ETI. I usually work on the query grid, but I read somewhere there is a limit to the length of expression. So I ended up editing the expression in SQL view, but somehow doesn't work.
Working before editing:
Code:
SELECT [Salaries YTD].[Emp#], [ETI Filter].ETI1, Sum([Salaries YTD].DaysWorked) AS SumOfDaysWorked, IIf([SumOfGross] Between 0 And 2000 And [ETI1]=1000,[SumOfGross]*([DaysWorked]/(DateDiff("ww",[Forms]![PeriodSelector]![FromDate],[Forms]![PeriodSelector]![ToDate],6)*5)*0.5),IIf([SumOfGross] Between 2001 And 4000 And [ETI1]=1000,1000,IIf([SumOfGross] Between 4001 And 6000 And [ETI1]=1000,1000-(0.5*([SumOfGross]-4000))))) AS ETI, DateDiff("ww",[Forms]![PeriodSelector]![FromDate],[Forms]![PeriodSelector]![ToDate],6) AS Weeks, Sum([Salaries YTD].Gross) AS SumOfGross1
FROM ETIGross INNER JOIN ([Salaries YTD] INNER JOIN [ETI Filter] ON [Salaries YTD].[Emp#] = [ETI Filter].[Emp#]) ON ETIGross.[Emp#] = [Salaries YTD].[Emp#]
WHERE ((([Salaries YTD].Date) Between [Forms]![PeriodSelector]![FromDate] And [Forms]![PeriodSelector]![ToDate]))
GROUP BY [Salaries YTD].[Emp#], [ETI Filter].ETI1, IIf([SumOfGross] Between 0 And 2000 And [ETI1]=1000,[SumOfGross]*([DaysWorked]/(DateDiff("ww",[Forms]![PeriodSelector]![FromDate],[Forms]![PeriodSelector]![ToDate],6)*5)*0.5),IIf([SumOfGross] Between 2001 And 4000 And [ETI1]=1000,1000,IIf([SumOfGross] Between 4001 And 6000 And [ETI1]=1000,1000-(0.5*([SumOfGross]-4000))))), DateDiff("ww",[Forms]![PeriodSelector]![FromDate],[Forms]![PeriodSelector]![ToDate],6);
Not working after adding lines:
Code:
SELECT [Salaries YTD].[Emp#], [ETI Filter].ETI1, Sum([Salaries YTD].DaysWorked) AS SumOfDaysWorked,
IIf([SumOfGross] Between 0 And 2000 And [ETI1]=1000,[SumOfGross]*([DaysWorked]/(DateDiff("ww",[Forms]![PeriodSelector]![FromDate],[Forms]![PeriodSelector]![ToDate],6)*5)*0.5),
IIf([SumOfGross] Between 0 And 2000 And [ETI1]=500,[SumOfGross]*([DaysWorked]/(DateDiff("ww",[Forms]![PeriodSelector]![FromDate],[Forms]![PeriodSelector]![ToDate],6)*5)*0.25),
IIf([SumOfGross] Between 2001 And 4000 And [ETI1]=1000,1000,
IIf([SumOfGross] Between 2001 And 4000 And [ETI1]=500,500,
IIf([SumOfGross] Between 4001 And 6000 And [ETI1]=500,500-(0.25*([SumOfGross]-4000,
IIf([SumOfGross] Between 4001 And 6000 And [ETI1]=1000,1000-(0.5*([SumOfGross]-4000)))))))) AS ETI,
DateDiff("ww",[Forms]![PeriodSelector]![FromDate],[Forms]![PeriodSelector]![ToDate],6) AS Weeks, Sum([Salaries YTD].Gross) AS SumOfGross1
FROM ETIGross INNER JOIN ([Salaries YTD] INNER JOIN [ETI Filter] ON [Salaries YTD].[Emp#] = [ETI Filter].[Emp#]) ON ETIGross.[Emp#] = [Salaries YTD].[Emp#]
WHERE ((([Salaries YTD].Date) Between [Forms]![PeriodSelector]![FromDate] And [Forms]![PeriodSelector]![ToDate]))
GROUP BY [Salaries YTD].[Emp#], [ETI Filter].ETI1, IIf([SumOfGross] Between 0 And 2000 And [ETI1]=1000,[SumOfGross]*([DaysWorked]/(DateDiff("ww",[Forms]![PeriodSelector]![FromDate],[Forms]![PeriodSelector]![ToDate],6)*5)*0.5),IIf([SumOfGross] Between 2001 And 4000 And [ETI1]=1000,1000,IIf([SumOfGross] Between 4001 And 6000 And [ETI1]=1000,1000-(0.5*([SumOfGross]-4000))))), DateDiff("ww",[Forms]![PeriodSelector]![FromDate],[Forms]![PeriodSelector]![ToDate],6);
Pete