lwidjaya said:
This is my query:
SELECT DatePart("yyyy",[Date]) AS AYear,
DatePart("m",[Date]) AS AMonth,
Sum(IIf([EMP]='FRANCE, SALES' And DatePart('m',[Date])=[AMonth]
And DatePart('yyyy',[Date])=[AYear],[SplitAmount],0)) AS FR,
Sum(IIf([EMP]='ABC, IN' And DatePart('m',[Date])=[AMonth]
And DatePart('yyyy',[Date])=[AYear],[SplitAmount],0)) AS IN,
Sum(IIf([EMP]='AR, SALES' And DatePart('m',[Date])=[AMonth]
And DatePart('yyyy',[Date])=[AYear],[SplitAmount],0)) AS AR,
Format([Date],"mmm") AS FDate,
Sum(IIf(DatePart('m',[Date])=[AMonth]
And DatePart('yyyy',[Date])=[AYear],[SplitAmount],0)) AS Total
INTO tblSalesTallySummary1
FROM tblSalesTally1
GROUP BY DatePart("yyyy",[Date]),
DatePart("m",[Date]),
Format([Date],"mmm")
It doesn't make sense for me because it works in one computer but not on
another?
The reason I used DSUM was because there are some conditions involved.
Even with all those conditions, I still prefer Sum over
DSum, especially if you should ever add a Where clause to
the query.
After making it more readable, I still don't see anything
that would cause a problem on one machine. I don't see
anything where different table contents would glitch things
up either. Have you verified that all the references are ok
on the problem machine? Does everything else work on both
machines?
As little as that is, that's the best I can do about your
specific question.
BUT, you said this query is to be used as a report's record
source, right? If so, I do not understand why you are doing
all that in the query. If the report is grouping on the EMP
field (and the month year combination), I would think it
would be a LOT easier to use a plain, ordinary Sum
expression in the report/group header/footer sections.
Without all that glop, it would be a very simple query and a
pretty straightforward report.