D
DBarker
Below is my union query. Now I am trying to set it up
that the user can ask for a specific department and
budget year. If I take the criteria out of one of the
select queries it brings back multiple entries of the
same data. But if I leave the criteria in I get asked
twice to enter a department number. Any ideas how I can
fix this problem?
----------------------------------------------------
SELECT [Annual Budget Query].[Account #], [Annual Budget
Query].Name_of_Account, [Annual Budget Query].[Department
#], [Annual Budget Query].Department_Name, [Annual Budget
Query].[Budget Year], Sum((Nz([SumOfAmount]))) AS Amount,
Sum((Nz([Annual Budget]))) AS Budget
FROM [Annual Budget Query] LEFT JOIN [Account Charges
Query] ON [Annual Budget Query].[Account #] = [Account
Charges Query].[Account #]
GROUP BY [Annual Budget Query].[Account #], [Annual
Budget Query].Name_of_Account, [Annual Budget Query].
[Department #], [Annual Budget Query].Department_Name,
[Annual Budget Query].[Budget Year]
HAVING ((([Annual Budget Query].[Department #])=[Enter
Department #]) AND (([Annual Budget Query].[Budget Year])=
[Enter Budget Year]))
UNION SELECT [Account Charges Query].[Account #],
[Account Charges Query].Name_of_Account, [Account Charges
Query].[Department #], [Account Charges
Query].Department_Name, [Account Charges Query].[Budget
Year], Sum((Nz([SumOfAmount]))) AS Amount, Sum((Nz
([Annual Budget]))) AS Budget
FROM [Account Charges Query] LEFT JOIN [Annual Budget
Query] ON [Account Charges Query].[Account #] = [Annual
Budget Query].[Account #]
GROUP BY [Account Charges Query].[Account #], [Account
Charges Query].Name_of_Account, [Account Charges Query].
[Department #], [Account Charges Query].Department_Name,
[Account Charges Query].[Budget Year]
HAVING ((([Account Charges Query].[Department #])=[Enter
Department Number]) AND (([Account Charges Query].[Budget
Year])=[Enter Budget Year]));
that the user can ask for a specific department and
budget year. If I take the criteria out of one of the
select queries it brings back multiple entries of the
same data. But if I leave the criteria in I get asked
twice to enter a department number. Any ideas how I can
fix this problem?
----------------------------------------------------
SELECT [Annual Budget Query].[Account #], [Annual Budget
Query].Name_of_Account, [Annual Budget Query].[Department
#], [Annual Budget Query].Department_Name, [Annual Budget
Query].[Budget Year], Sum((Nz([SumOfAmount]))) AS Amount,
Sum((Nz([Annual Budget]))) AS Budget
FROM [Annual Budget Query] LEFT JOIN [Account Charges
Query] ON [Annual Budget Query].[Account #] = [Account
Charges Query].[Account #]
GROUP BY [Annual Budget Query].[Account #], [Annual
Budget Query].Name_of_Account, [Annual Budget Query].
[Department #], [Annual Budget Query].Department_Name,
[Annual Budget Query].[Budget Year]
HAVING ((([Annual Budget Query].[Department #])=[Enter
Department #]) AND (([Annual Budget Query].[Budget Year])=
[Enter Budget Year]))
UNION SELECT [Account Charges Query].[Account #],
[Account Charges Query].Name_of_Account, [Account Charges
Query].[Department #], [Account Charges
Query].Department_Name, [Account Charges Query].[Budget
Year], Sum((Nz([SumOfAmount]))) AS Amount, Sum((Nz
([Annual Budget]))) AS Budget
FROM [Account Charges Query] LEFT JOIN [Annual Budget
Query] ON [Account Charges Query].[Account #] = [Annual
Budget Query].[Account #]
GROUP BY [Account Charges Query].[Account #], [Account
Charges Query].Name_of_Account, [Account Charges Query].
[Department #], [Account Charges Query].Department_Name,
[Account Charges Query].[Budget Year]
HAVING ((([Account Charges Query].[Department #])=[Enter
Department Number]) AND (([Account Charges Query].[Budget
Year])=[Enter Budget Year]));