A
Adam
Using Access 2003 on Windows XP
I have three tables
tblCategories with just category names and ID numbers
tblExpense with fields for date of expense, amount of expense and which
category the expense is in (related to tblCategory)
tblBudget with fields for year, month, category, and amount budgeted
I have the following query, qryExpenseSum, to sum the expenses for each
month for each category:
SELECT DatePart("yyyy",[dteDate]) AS numYear, DatePart("m",[dteDate]) AS
numMonth, tblExpense.numCategory, Sum(tblExpense.curAmount) AS SumOfcurAmount
FROM tblExpense
GROUP BY DatePart("yyyy",[dteDate]), DatePart("m",[dteDate]),
tblExpense.numCategory
HAVING (((DatePart("yyyy",[dteDate]))=[forms]![frmHome].[numYear]));
What I would like is to create another query that puts the total amount
spent next to the amount budgeted for each category in each month so that I
can find the difference and put it in a report. I was almost able to acheive
that with the following query
SELECT qryExpenseSum.numYear, qryExpenseSum.numMonth,
qryExpenseSum.numCategory, tblCategory.strCategory, tblBudget.curBudget,
qryExpenseSum.SumOfcurAmount, [curBudget]-[SumOfcurAmount] AS curDifference
FROM (qryExpenseSum INNER JOIN tblCategory ON qryExpenseSum.numCategory =
tblCategory.anuCategoryID) INNER JOIN tblBudget ON (qryExpenseSum.numCategory
= tblBudget.numCategory) AND (qryExpenseSum.numMonth = tblBudget.numMonth);
....but if there was nothing spent in a particular category in a particular
month, it does not show up in the query for that month. I have tried setting
the relationship in the first query to include all records from tblExpense
(with an nz to make it show up as $0 for unused categories), but over the
course of a year all of the categories are used, just not in every month.
Sorry for the long winded explanation, I just wanted to answer as many
questions as I could before they were asked. Thank you.
Adam
I have three tables
tblCategories with just category names and ID numbers
tblExpense with fields for date of expense, amount of expense and which
category the expense is in (related to tblCategory)
tblBudget with fields for year, month, category, and amount budgeted
I have the following query, qryExpenseSum, to sum the expenses for each
month for each category:
SELECT DatePart("yyyy",[dteDate]) AS numYear, DatePart("m",[dteDate]) AS
numMonth, tblExpense.numCategory, Sum(tblExpense.curAmount) AS SumOfcurAmount
FROM tblExpense
GROUP BY DatePart("yyyy",[dteDate]), DatePart("m",[dteDate]),
tblExpense.numCategory
HAVING (((DatePart("yyyy",[dteDate]))=[forms]![frmHome].[numYear]));
What I would like is to create another query that puts the total amount
spent next to the amount budgeted for each category in each month so that I
can find the difference and put it in a report. I was almost able to acheive
that with the following query
SELECT qryExpenseSum.numYear, qryExpenseSum.numMonth,
qryExpenseSum.numCategory, tblCategory.strCategory, tblBudget.curBudget,
qryExpenseSum.SumOfcurAmount, [curBudget]-[SumOfcurAmount] AS curDifference
FROM (qryExpenseSum INNER JOIN tblCategory ON qryExpenseSum.numCategory =
tblCategory.anuCategoryID) INNER JOIN tblBudget ON (qryExpenseSum.numCategory
= tblBudget.numCategory) AND (qryExpenseSum.numMonth = tblBudget.numMonth);
....but if there was nothing spent in a particular category in a particular
month, it does not show up in the query for that month. I have tried setting
the relationship in the first query to include all records from tblExpense
(with an nz to make it show up as $0 for unused categories), but over the
course of a year all of the categories are used, just not in every month.
Sorry for the long winded explanation, I just wanted to answer as many
questions as I could before they were asked. Thank you.
Adam