J
Jaazaniah
Ok, I'm having to re-vamp a reporting system, and in the midst, was
altering this query to work with the new underlaying queries.However,
it appears that the subquery YTD is now bugging out and this query
won't run, saying [mpl].[Year] is not a valid fieldname (or
expression). I've scoured this query many times and can't figure out
why the subquery can't refer to mpl properly. As a further point, the
query runs perfectly as expected without the subquery field [YTD]. Any
advise would be appreciated.
SELECT mpl.HiddenLink, mpl.ChartGroup, mpl.Year, mpl.Month,
mpl.Procedure, qryMonthlyInPatients.*, qryMonthlyOutPatients.*,
mpr2.Totals, (select Nz(sum([Totals]),0) as Sums from
[qryMonthlyProductionReport2] as mpr1 where [mpr1].[Year]=[mpl].[Year]
AND [mpr1].[Procedure]=[mpl].[Procedure] AND [mpr1].[Month]<=[mpl].
[Month]) AS YTD
FROM qryMonthlyInPatients RIGHT JOIN (qryMonthlyOutPatients RIGHT JOIN
(qryMonthlyProductionList AS mpl LEFT JOIN qryMonthlyProductionReport2
AS mpr2 ON mpl.HiddenLink = mpr2.HiddenLink) ON
qryMonthlyOutPatients.HiddenLink = mpl.HiddenLink) ON
qryMonthlyInPatients.HiddenLink = mpl.HiddenLink
ORDER BY mpl.HiddenLink;
altering this query to work with the new underlaying queries.However,
it appears that the subquery YTD is now bugging out and this query
won't run, saying [mpl].[Year] is not a valid fieldname (or
expression). I've scoured this query many times and can't figure out
why the subquery can't refer to mpl properly. As a further point, the
query runs perfectly as expected without the subquery field [YTD]. Any
advise would be appreciated.
SELECT mpl.HiddenLink, mpl.ChartGroup, mpl.Year, mpl.Month,
mpl.Procedure, qryMonthlyInPatients.*, qryMonthlyOutPatients.*,
mpr2.Totals, (select Nz(sum([Totals]),0) as Sums from
[qryMonthlyProductionReport2] as mpr1 where [mpr1].[Year]=[mpl].[Year]
AND [mpr1].[Procedure]=[mpl].[Procedure] AND [mpr1].[Month]<=[mpl].
[Month]) AS YTD
FROM qryMonthlyInPatients RIGHT JOIN (qryMonthlyOutPatients RIGHT JOIN
(qryMonthlyProductionList AS mpl LEFT JOIN qryMonthlyProductionReport2
AS mpr2 ON mpl.HiddenLink = mpr2.HiddenLink) ON
qryMonthlyOutPatients.HiddenLink = mpl.HiddenLink) ON
qryMonthlyInPatients.HiddenLink = mpl.HiddenLink
ORDER BY mpl.HiddenLink;