Solved

Compare 2 Table

Posted on 2000-04-19
4
159 Views
Last Modified: 2010-05-02
How can I compare an old table with a new table in order to filter out the new records added to the new table.

Thanks.
0
Comment
Question by:choonfong
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 18

Accepted Solution

by:
deighton earned 50 total points
ID: 2730181
Open both tables,
read new table a record a time.
do a oldtable.FindFirst on the old table looking for records matching those in new table.

if oldtable.nomatch = true then record is new

0
 
LVL 10

Expert Comment

by:caraf_g
ID: 2730220
Hi choonfong,

A very similar question has been asked in http://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=10330744 
See my comments there.

You can use a similar technique on recordsets, provided they're ordered.
0
 
LVL 10

Expert Comment

by:caraf_g
ID: 2730225
Just in case you don't know, you can get an ordered recordset quite easily by using an sql statement such as

"SELECT * FROM YOURTABLE WHERE SOMECONDITION ORDER BY UNIQUEFIELDS"

Make sure the order criteria make up a unique key otherwise you'll have trouble finding out whether two records with identical criteria are in fact the same record ;-)
0
 
LVL 2

Expert Comment

by:brice123
ID: 2730252
You could use a simple SQL statement.
For example (in MS-SQL 7) :

select
      t1.SectorID,
      t1.Description
from
      Sectors t1
left outer join
      NewSectors t2
on       t1.SectorID = t2.SectorID
where      
      t2.Description is Null
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question