K
kratz
I've had this query working in the past, but I made some adjustments, and now
the query is too complex.
I am trying to group/sum per agent number per account.
SELECT qryCurrentExpDeductions.[CustAgt Number],
qryCurrentExpDeductions.[Customer Number], qryCurrentExpDeductions.[Agent
Number], Sum(qryCurrentExpDeductions.ExpToDate) AS SumOfExpToDate,
qryCurrentExpDeductions.Comments
FROM qryCurrentExpDeductions
GROUP BY qryCurrentExpDeductions.[CustAgt Number],
qryCurrentExpDeductions.[Customer Number], qryCurrentExpDeductions.[Agent
Number], qryCurrentExpDeductions.Comments;
Underlying Query 'qryCurrentExpDeductions':
SELECT qryExpectedDeductions.[CustAgt Number],
qryExpectedDeductions.[Customer Number], qryExpectedDeductions.[Agent
Number], qryExpectedDeductions.ExpToDate, qryExpectedDeductions.Comments
FROM qryExpectedDeductions
WHERE
(((qryExpectedDeductions.StartLookup)<[qryExpectedDeductions]![CurrentLookup]
Or
(qryExpectedDeductions.StartLookup)=[qryExpectedDeductions]![CurrentLookup]));
Underlying Query 'qryExpectedDeductions':
SELECT Deductions.[Customer Number], Deductions.[Agent Number],
Deductions![Customer Number]+Deductions![Agent Number] AS [CustAgt Number],
IIf(Deductions!Updated=Yes,Deductions!UpdatedMoDeductions,Deductions!OriginalMoDeduction)
AS MonthlyDeduction,
IIf(Deductions!Updated=Yes,Deductions!UpdatedTotalDeduction,Deductions!OriginalTotalDeduction)
AS TotalDeduct,
IIf(Deductions!Updated=Yes,CInt(Deductions!UpdatedNoMonths),CInt(Deductions!OriginalNoMonths))
AS NoOfMonths,
IIf(Deductions!Updated=Yes,Deductions!UpdatedStartMonth,Deductions!OriginalStartMonth)
AS StartMonth, CStr(Forms!frmAgentDifferences!cboSelectMonth) AS
CurrentMonth,
Int(DLookUp("[Months]![MonthIndex]","[Months]","[Months]![Month] = '" &
[StartMonth] & "'")) AS StartLookup,
Int(DLookUp("[Months]![MonthIndex]","[Months]","[Months]![Month] = '" &
[Forms]![frmAgentDifferences]![cboSelectMonth] & "'")) AS CurrentLookup,
-CCur(IIf(((([CurrentLookup]-[StartLookup])+1)<[NoOfMonths]),((([CurrentLookup]-[StartLookup])+1)*[OriginalMoDeduction]),[TotalDeduct]))
AS ExpToDate, Deductions.Comments
FROM tblSOAccountInfo INNER JOIN (Deductions INNER JOIN Months ON
Deductions.OriginalStartMonth = Months.Month) ON (tblSOAccountInfo.[Customer
Number] = Deductions.[Customer Number]) AND (tblSOAccountInfo.[Customer
Number] = Deductions.[Customer Number])
WHERE (((tblSOAccountInfo.[Open/Closed])=No));
Originally, I had this in just two queries, but I was having a 'too complex'
issue, so I split it so that I could at least get part of this done.
Thanks for the help!
the query is too complex.
I am trying to group/sum per agent number per account.
SELECT qryCurrentExpDeductions.[CustAgt Number],
qryCurrentExpDeductions.[Customer Number], qryCurrentExpDeductions.[Agent
Number], Sum(qryCurrentExpDeductions.ExpToDate) AS SumOfExpToDate,
qryCurrentExpDeductions.Comments
FROM qryCurrentExpDeductions
GROUP BY qryCurrentExpDeductions.[CustAgt Number],
qryCurrentExpDeductions.[Customer Number], qryCurrentExpDeductions.[Agent
Number], qryCurrentExpDeductions.Comments;
Underlying Query 'qryCurrentExpDeductions':
SELECT qryExpectedDeductions.[CustAgt Number],
qryExpectedDeductions.[Customer Number], qryExpectedDeductions.[Agent
Number], qryExpectedDeductions.ExpToDate, qryExpectedDeductions.Comments
FROM qryExpectedDeductions
WHERE
(((qryExpectedDeductions.StartLookup)<[qryExpectedDeductions]![CurrentLookup]
Or
(qryExpectedDeductions.StartLookup)=[qryExpectedDeductions]![CurrentLookup]));
Underlying Query 'qryExpectedDeductions':
SELECT Deductions.[Customer Number], Deductions.[Agent Number],
Deductions![Customer Number]+Deductions![Agent Number] AS [CustAgt Number],
IIf(Deductions!Updated=Yes,Deductions!UpdatedMoDeductions,Deductions!OriginalMoDeduction)
AS MonthlyDeduction,
IIf(Deductions!Updated=Yes,Deductions!UpdatedTotalDeduction,Deductions!OriginalTotalDeduction)
AS TotalDeduct,
IIf(Deductions!Updated=Yes,CInt(Deductions!UpdatedNoMonths),CInt(Deductions!OriginalNoMonths))
AS NoOfMonths,
IIf(Deductions!Updated=Yes,Deductions!UpdatedStartMonth,Deductions!OriginalStartMonth)
AS StartMonth, CStr(Forms!frmAgentDifferences!cboSelectMonth) AS
CurrentMonth,
Int(DLookUp("[Months]![MonthIndex]","[Months]","[Months]![Month] = '" &
[StartMonth] & "'")) AS StartLookup,
Int(DLookUp("[Months]![MonthIndex]","[Months]","[Months]![Month] = '" &
[Forms]![frmAgentDifferences]![cboSelectMonth] & "'")) AS CurrentLookup,
-CCur(IIf(((([CurrentLookup]-[StartLookup])+1)<[NoOfMonths]),((([CurrentLookup]-[StartLookup])+1)*[OriginalMoDeduction]),[TotalDeduct]))
AS ExpToDate, Deductions.Comments
FROM tblSOAccountInfo INNER JOIN (Deductions INNER JOIN Months ON
Deductions.OriginalStartMonth = Months.Month) ON (tblSOAccountInfo.[Customer
Number] = Deductions.[Customer Number]) AND (tblSOAccountInfo.[Customer
Number] = Deductions.[Customer Number])
WHERE (((tblSOAccountInfo.[Open/Closed])=No));
Originally, I had this in just two queries, but I was having a 'too complex'
issue, so I split it so that I could at least get part of this done.
Thanks for the help!