D
DBarker
below is a union query that am using, but what I want is
the user to specify what dept. # and Budget year they
want to display. I have tried to combine but keep
getting syntax error messages. Does anyone know the
correct syntax so that the user only has to enter the
information one. I initially had the criteria listed
separately in each select statement which did work but it
required them to enter the same information twice.
Any help would be appreciated.
Debbie
----------------------------------------------------------
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]
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 ((([Annual Budget Query].[Department #]OR[Account
to Budget].[Department #])=[Enter Department #]) OR
(([Annual Budget Query].[Budget Year], (Account Charges
Query].[Budget Year])=[Enter Budget Year]));
the user to specify what dept. # and Budget year they
want to display. I have tried to combine but keep
getting syntax error messages. Does anyone know the
correct syntax so that the user only has to enter the
information one. I initially had the criteria listed
separately in each select statement which did work but it
required them to enter the same information twice.
Any help would be appreciated.
Debbie
----------------------------------------------------------
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]
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 ((([Annual Budget Query].[Department #]OR[Account
to Budget].[Department #])=[Enter Department #]) OR
(([Annual Budget Query].[Budget Year], (Account Charges
Query].[Budget Year])=[Enter Budget Year]));