Dear George:
This is pretty scanty information, but I'll tell you what I can.
In the query results you would have a column for TotalExpense. In the
case that the ExpenseName is Admin, you want to subtract the totals
for two other ExpenseName categories called 'Deferred Comp' and
'Interest'. You would probably need to retrieve the total of each of
these with subqueries. You also might want to omit these two from the
overall query, since you're already accounting for them.
Begin with a totals query that gives you just the basic totals for
each account. I may look like this:
SELECT ExpenseName, SUM(ExpenseAmount) AS TotalExpense
FROM YourTable
GROUP BY ExpenseName
The modification for your needs would then be:
SELECT ExpenseName,
IIf(ExpenseName = "Admin expense",
SUM(ExpenseAmount) - (SELECT SUM(ExpenseAmount) FROM YourTable
WHERE ExpenseName = IN("Deffered Comp", "interest")),
SUM(ExpenseAmount))
FROM YourTable
WHERE ExpenseName NOT IN ("Deffered Comp", "interest")
GROUP BY ExpenseName
You must fix this up for the actual names of your table and columns,
and the exact ExpenseName values required.
You may want to remove the next-to-last line if you do want to see the
Deffered Comp and interest rows in addition to subtracting them. I
put this in in case you would want to omit them, as it's easier to
take code out than to have to add it, expecially if you don't know
what it is!
A final note. In my experience with accounting, it is often said you
should subtract something when, in actuality, the value is already
negative and, in computer terms, you need to add it. So, you may want
to change the - to + in line 3.
I made enough assumptions here to fill a bucket or two. You may need
to post additional information here if I was far off.
Tom Ellison
Microsoft Access MVP
Ellison Enterprises - Your One Stop IT Experts