Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 3rd, 2006, 04:25 AM
Authorized User
 
Join Date: Jul 2006
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to lawsoncobol
Default Compare two table - Find missing record

Hi friends

i have two Ms access database files with same structure and same data

Example

File 1

Row (Key) SSN Tax Salary Gross
1 3 6 7 9
2 4 6 8 10
Missing record---------------------


File2
Row (Key) SSN Tax Salary Gross
1 3 5 7 9
2 4 6 8 10
3 11 12 13 14

Note : In file1 first row the value of tax are different

My SQL query is
--------------------------------------------------------------------
SELECT
File2.row, File2.SSN, File2.QtrTxbl, File2.QtrTxbl, File2.YtdTxbl, File2.QtrAmt, File2.YtdAmt, File2.QtrGross, File2.YtdGross

FROM File2 LEFT JOIN File1 ON File2.SSN=File1.SSN

WHERE (((File1.SSN) Is Null));

--------------------------------------------------------------------

I want Qury to return only 3rd record in file2 as that one is Null in file1 (missing in file1 but present in file2)

The problem is its retrieving first row and the missing record too

Can anyone help me with this?


Thanks and Regards
Lawson, COBOL
__________________
Thanks and Regards
Lawson, COBOL
 
Old August 3rd, 2006, 04:58 AM
Authorized User
 
Join Date: Jul 2006
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi lawsoncobol

Try using the 'Find unmatch query wizard'.

SQL
------------------------------------------------
SELECT [Copy Of Table1].id, [Copy Of Table1].Q1, [Copy Of Table1].Q1A, [Copy Of Table1].Q1B, [Copy Of Table1].Q2, [Copy Of Table1].Q3, [Copy Of Table1].Q4, [Copy Of Table1].Q5, [Copy Of Table1].Q6, [Copy Of Table1].Q7, [Copy Of Table1].Q7A, [Copy Of Table1].Q7B, [Copy Of Table1].Q8, [Copy Of Table1].Q8A, [Copy Of Table1].Q9, [Copy Of Table1].Q9A, [Copy Of Table1].Q9B, [Copy Of Table1].Q10
FROM [Copy Of Table1] LEFT JOIN Table1 ON [Copy Of Table1].id = Table1.id
WHERE (((Table1.id) Is Null));
-----------------------------------------------------
The sql code that I have pasted her was between 'Table1' and 'Copy Of Table1'. If this don't work please let me know then we can try something else.

Cheers
Hennie

 
Old August 3rd, 2006, 05:22 AM
Authorized User
 
Join Date: Jul 2006
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to lawsoncobol
Default

Hello Hennie

My SQL code
SELECT
File2.row, File2.SSN, File2.QtrTxbl, File2.QtrTxbl, File2.YtdTxbl, File2.QtrAmt, File2.YtdAmt, File2.QtrGross, File2.YtdGross
FROM File2 LEFT JOIN File1 ON File2.SSN=File1.SSN
WHERE (((File1.SSN) Is Null));

AND your SQL code

SELECT [Copy Of Table1].id, [Copy Of Table1].Q1, [Copy Of Table1].Q1A, [Copy Of Table1].Q1B, [Copy Of Table1].Q2, [Copy Of Table1].Q3, [Copy Of Table1].Q4, [Copy Of Table1].Q5, [Copy Of Table1].Q6, [Copy Of Table1].Q7, [Copy Of Table1].Q7A, [Copy Of Table1].Q7B, [Copy Of Table1].Q8, [Copy Of Table1].Q8A, [Copy Of Table1].Q9, [Copy Of Table1].Q9A, [Copy Of Table1].Q9B, [Copy Of Table1].Q10
FROM [Copy Of Table1] LEFT JOIN Table1 ON [Copy Of Table1].id = Table1.id
WHERE (((Table1.id) Is Null));

BOTH ARE ACTUALLY SAME TRY RELACE ALL WORDS Copy Of Table1 with File2 and TABLE1 = file1 and ID with SSN
and it becomes my code

Anyway i tried putting [] as u did but nothing worked


Thanks and Regards
Lawson, COBOL
 
Old August 3rd, 2006, 06:09 AM
Authorized User
 
Join Date: Jul 2006
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Lawson

I create DB with your field name and data that you have supplied me with. I have picked up date you have a few other field name in your table, you can just add those ones to this code. I have use the sql below and it works. If this doesn't work, feel free to drop me a mail.

----------------------------------------
SELECT
TBL2.Row, TBL2.SSN, TBL2.Salary, TBL2.Gross
FROM TBL2 LEFT JOIN TBL1 ON TBL2.SSN = TBL1.SSN
WHERE (((TBL1.SSN) Is Null));

 
Old August 3rd, 2006, 09:32 AM
pjm pjm is offline
Authorized User
 
Join Date: Jul 2006
Posts: 70
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Just change your WHERE clause to:

WHERE (((File1.SSN) Is Null) OR (File1.Tax <> File2.Tax) OR (File1.Salary <> File2.Salary) OR (File1.Gross <> File2.Gross));


-Phil-
 
Old August 4th, 2006, 01:18 AM
Authorized User
 
Join Date: Jul 2006
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to lawsoncobol
Default

hi phil and hennie,
 thans for the effort it works fine now.

Thanks and Regards
Lawson, COBOL





Similar Threads
Thread Thread Starter Forum Replies Last Post
Compare Form Data against varchar DB record. iloveoatmeal Classic ASP Databases 16 July 2nd, 2007 01:40 PM
Compare Two MS access db file and find missing rec lawsoncobol Reporting Services 0 August 3rd, 2006 04:14 AM
Anybody find the missing code in ch6? nickolas BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 1 January 29th, 2006 10:38 AM
Compare FE table with same BE version of table amerk20 Access VBA 5 November 29th, 2004 04:51 PM
Find out missing record hari-kumar-vadakkeveedu SQL Server 2000 3 October 15th, 2004 01:09 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.