SELECT [Subtotal Data].[Cost Center]
, [Group Names by Account].Description
, [Subtotal Data].[Cost Category]
, [OB Budgets by Categ].Budget
, [Subtotal Data].[Current Month] AS [Current Month Cost]
, [Subtotal Data].[Year-to-Date] AS [Year-to-Date Cost]
, [Year-to-Date Cost]/[Budget] AS [Percent Spent]
FROM ([Subtotal Data] LEFT JOIN [OB Budgets by Categ]
ON ([Subtotal Data].[Cost Category] = [OB Budgets by Categ].[Cost Category])
AND ([Subtotal Data].[Cost Center] = [OB Budgets by Categ].[OB Account]))
LEFT JOIN [Group Names by Account]
ON [Subtotal Data].[Cost Center] = [Group Names by Account].[Cost Center]
WHERE ((([OB Budgets by Categ].Budget)<>0))
OR ((([Subtotal Data].[Current Month])<>0))
OR ((([Subtotal Data].[Year-to-Date])<>0));
Your where clause is overiding the left joins ability to give you all the
records. You can try changing it to
WHERE [OB Budgets by Categ].Budget<>0
OR [Subtotal Data].[Current Month]<>0
OR [Subtotal Data].[Current Month] is Null
OR [Subtotal Data].[Year-to-Date]<>0
OR [Subtotal Data].[Year-to-Date] is Null
Another problem is that probably want to use a RIGHT JOIN in the above and not
a LEFT JOIN. The LEFT JOIN (without criteria) would return all records in
SubTotal data and only matching records in Group Names by Account. I think
you want the other way round.
Or you can try dropping all the criteria on SubTotal Data table.
Or you are going to need to use nested queries - where you get the information
from SubTotal Data in a separate query and then use the separate query in
place of the table in the above query.
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
Is this what you're referring to?
SELECT [Subtotal Data].[Cost Center], [Group Names by Account].Description,
[Subtotal Data].[Cost Category], [OB Budgets by Categ].Budget, [Subtotal
Data].[Current Month] AS [Current Month Cost], [Subtotal Data].[Year-to-Date]
AS [Year-to-Date Cost], [Year-to-Date Cost]/[Budget] AS [Percent Spent]
FROM ([Subtotal Data] LEFT JOIN [OB Budgets by Categ] ON ([Subtotal
Data].[Cost Category] = [OB Budgets by Categ].[Cost Category]) AND ([Subtotal
Data].[Cost Center] = [OB Budgets by Categ].[OB Account])) LEFT JOIN [Group
Names by Account] ON [Subtotal Data].[Cost Center] = [Group Names by
Account].[Cost Center]
WHERE ((([OB Budgets by Categ].Budget)<>0)) OR ((([Subtotal Data].[Current
Month])<>0)) OR ((([Subtotal Data].[Year-to-Date])<>0));
mscertified said:
The first thing to determine is if you have the data in your report record
source. In design view for the report click View--Properties--Data--Record
source.
You will then need to go to that query and post the SQL so we can look at
it. I'm assuming the record source is a query because you say the data comes
from two tables.
-Dorian