A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Setting Up & Running Reports
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Comparing data in two tables



 
 
Thread Tools Display Modes
  #1  
Old August 13th, 2007, 10:36 PM posted to microsoft.public.access.reports
ivysgarden
external usenet poster
 
Posts: 1
Default Comparing data in two tables

I am trying to print out a report that compares two tables. The tables have
the same headings. One table is from my department and the other table is
from another department. I need to make sure that we balance (which we NEVER
do). So I need to be able to show which records are not balancing.

Simple enough. Now my dilema.
The information could have duplicate records in either table, thus
duplicating the amount.

SAMPLE:
Table 1:
File# Veh $ Misc $
07-145678 $3,639

Table 2:
File# Veh $ Misc $
07-145678 $3,639 $300
07-145678 $500


REPORT shows:
File# Veh $ Misc $ Veh $ Misc $
07-145678 $3,639 $3,639 $300
07-145678 $3,639 $500

I even tried doing it through a querry and I get the same thing. If the file
has two or more records associated with it then I get it duplicated on the
report. I even tried to do a sum of the records with the same file #......
that did not work.

HELP


  #2  
Old August 13th, 2007, 11:50 PM posted to microsoft.public.access.reports
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default Comparing data in two tables

I used four queries. If you know subqueries you could do it with less.
ivysgarden_0 ---
SELECT [Table 1].[File#]
FROM [Table 1]
GROUP BY [Table 1].[File#]
UNION ALL SELECT [Table 2].[File#]
FROM [Table 2]
GROUP BY [Table 2].[File#];

ivysgarden_1 ---
SELECT [Table 1].[File#], Sum([Table 1].[Veh $]) AS [SumOfVeh $], Sum([Table
1].[Misc $]) AS [SumOfMisc $]
FROM [Table 1]
GROUP BY [Table 1].[File#];

ivysgarden_2 ---
SELECT [Table 2].[File#], Sum([Table 2].[Veh $]) AS [SumOfVeh $], Sum([Table
2].[Misc $]) AS [SumOfMisc $]
FROM [Table 2]
GROUP BY [Table 2].[File#];

SELECT ivysgarden_0.[File#], ivysgarden_1.[SumOfVeh $],
ivysgarden_1.[SumOfMisc $], ivysgarden_2.[SumOfVeh $],
ivysgarden_2.[SumOfMisc $]
FROM (ivysgarden_0 LEFT JOIN ivysgarden_1 ON ivysgarden_0.[File#] =
ivysgarden_1.[File#]) LEFT JOIN ivysgarden_2 ON ivysgarden_0.[File#] =
ivysgarden_2.[File#]
GROUP BY ivysgarden_0.[File#], ivysgarden_1.[SumOfVeh $],
ivysgarden_1.[SumOfMisc $], ivysgarden_2.[SumOfVeh $],
ivysgarden_2.[SumOfMisc $]
HAVING (((ivysgarden_2.[SumOfVeh $])=[ivysgarden_1].[SumOfVeh $])) OR
(((ivysgarden_2.[SumOfMisc $])=[ivysgarden_1].[SumOfMisc $]));

--
KARL DEWEY
Build a little - Test a little


"ivysgarden" wrote:

I am trying to print out a report that compares two tables. The tables have
the same headings. One table is from my department and the other table is
from another department. I need to make sure that we balance (which we NEVER
do). So I need to be able to show which records are not balancing.

Simple enough. Now my dilema.
The information could have duplicate records in either table, thus
duplicating the amount.

SAMPLE:
Table 1:
File# Veh $ Misc $
07-145678 $3,639

Table 2:
File# Veh $ Misc $
07-145678 $3,639 $300
07-145678 $500


REPORT shows:
File# Veh $ Misc $ Veh $ Misc $
07-145678 $3,639 $3,639 $300
07-145678 $3,639 $500

I even tried doing it through a querry and I get the same thing. If the file
has two or more records associated with it then I get it duplicated on the
report. I even tried to do a sum of the records with the same file #......
that did not work.

HELP


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 10:07 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.