Bruce,
This is confusing…I know. Sorry about that. I think it might be best to
give you the SQL from each query. Thanks for looking at this! If you happen
to know a better way to do this, then I'm all for it because I have to do the
same for year and quarter and then again by a different category.
Name: bqODCVar1
SELECT tblTrans_Mstr.TransDate, tblTrans_Mstr.Category, tblTrans_Mstr.Group,
tblTrans_Mstr.Product, tblTrans_Mstr.PA_Descriptions, tblTrans_Mstr.
Credit_GL_Acct, tblTrans_Mstr.ODC_Cost, 1 AS Mnth
FROM tblTrans_Mstr
WHERE (((([TransDate])) Like [Enter Current Month] & "*") AND ((Year(
[TransDate]))=[Enter Current Year]) AND ((Format([TransDate],"q"))=[Enter
Current QTR]))
GROUP BY tblTrans_Mstr.TransDate, tblTrans_Mstr.Category, tblTrans_Mstr.Group,
tblTrans_Mstr.Product, tblTrans_Mstr.PA_Descriptions, tblTrans_Mstr.
Credit_GL_Acct, tblTrans_Mstr.ODC_Cost, 1
HAVING (((tblTrans_Mstr.Group)="ODC"));
Name: bqODCVar2
SELECT tblTrans_Mstr.TransDate, tblTrans_Mstr.Category, tblTrans_Mstr.Group,
tblTrans_Mstr.Product, tblTrans_Mstr.PA_Descriptions, tblTrans_Mstr.
Credit_GL_Acct, tblTrans_Mstr.ODC_Cost, 2 AS Mnth
FROM tblTrans_Mstr
WHERE (((([TransDate])) Like [Enter Previous Month] & "*") AND ((Year(
[TransDate]))=[Enter Current or Previous Year]) AND ((Format([TransDate],"q"))
=[Enter Previous QTR]))
GROUP BY tblTrans_Mstr.TransDate, tblTrans_Mstr.Category, tblTrans_Mstr.Group,
tblTrans_Mstr.Product, tblTrans_Mstr.PA_Descriptions, tblTrans_Mstr.
Credit_GL_Acct, tblTrans_Mstr.ODC_Cost, 2
HAVING (((tblTrans_Mstr.Group)="ODC"));
Name: bqODCVar (this is my Union Query…as you will see)
SELECT tblTrans_Mstr.TransDate, tblTrans_Mstr.Category, tblTrans_Mstr.Group,
tblTrans_Mstr.Product, tblTrans_Mstr.PA_Descriptions, tblTrans_Mstr.
Credit_GL_Acct, tblTrans_Mstr.ODC_Cost, 1 AS Mnth
FROM tblTrans_Mstr
WHERE (((([TransDate])) Like [Enter Current Month] & "*") AND ((Year(
[TransDate]))=[Enter Current Year]) AND ((Format([TransDate],"q"))=[Enter
Current QTR]))
GROUP BY tblTrans_Mstr.TransDate, tblTrans_Mstr.Category, tblTrans_Mstr.Group,
tblTrans_Mstr.Product, tblTrans_Mstr.PA_Descriptions, tblTrans_Mstr.
Credit_GL_Acct, tblTrans_Mstr.ODC_Cost, 1
HAVING (((tblTrans_Mstr.Group)="ODC"));
UNION ALL SELECT tblTrans_Mstr.TransDate, tblTrans_Mstr.Category,
tblTrans_Mstr.Group, tblTrans_Mstr.Product, tblTrans_Mstr.PA_Descriptions,
tblTrans_Mstr.Credit_GL_Acct, tblTrans_Mstr.ODC_Cost, 2 AS Mnth
FROM tblTrans_Mstr
WHERE (((Month([TransDate])) Like [Enter Previous Month] & "*") AND ((Year(
[TransDate]))=[Enter Previous Year]) AND ((Format([TransDate],"q"))=[Enter
Previous QTR]))
GROUP BY tblTrans_Mstr.TransDate, tblTrans_Mstr.Category, tblTrans_Mstr.Group,
tblTrans_Mstr.Product, tblTrans_Mstr.PA_Descriptions, tblTrans_Mstr.
Credit_GL_Acct, tblTrans_Mstr.ODC_Cost, 2
HAVING (((tblTrans_Mstr.Group)="ODC"));
Name: qryODCVariance (my final query that I’m using for my report)
SELECT bqODCVar.Category, bqODCVar.Group, bqODCVar.Product, bqODCVar.
PA_Descriptions, bqODCVar.Credit_GL_Acct, Sum(IIf([Mnth]=2,[ODC_Cost],0)) AS
ODCPrevious, Sum(IIf([Mnth]=1,[ODC_Cost],0)) AS ODCCurrent, [ODCCurrent]-
[ODCPrevious] AS ODCDelta
FROM bqODCVar
GROUP BY bqODCVar.Category, bqODCVar.Group, bqODCVar.Product, bqODCVar.
PA_Descriptions, bqODCVar.Credit_GL_Acct
HAVING (((bqODCVar.Group)="ODC"));
You seem to be taking the long way around, but I can't quite understand what
you are trying to do. The thing that has me especially puzzled is that you
[quoted text clipped - 16 lines]