Dear All,
I want to compare two tables.
Both of the tables have same fields but their location in terms of columns can be different.
My target is to get those fields only whose values are found different on comparing.
Regards
Hasnain
3 2044 Rabbit 12,516
Recognized Expert Moderator MVP
We need more information. i.e. What fields are in the tables, how are they related, what kind of data do the tables hold, and when you say compare them, how is the comparison being made?
ADezii 8,834
Recognized Expert Expert
Dear All,
I want to compare two tables.
Both of the tables have same fields but their location in terms of columns can be different.
My target is to get those fields only whose values are found different on comparing.
Regards
Hasnain
With limited information, I'll have to make some assumptions:
__1 Table Names: Table1 and Table2
__2 Number of Fields: 4 in each Table
__3 Field Names: Field1, Field2, Field3, Field4
__4 Number of Records in each Table: irrelevant (as long as equal)
__5 This code is adaptable to include Record Numbers, more/less Fields, etc. To find the differences between Field values in each Table: - Dim MyDB As DAO.Database, MyRS As DAO.Recordset
-
Dim intCountOfFields As Integer, MyRS2 As DAO.Recordset
-
-
Set MyDB = CurrentDb()
-
Set MyRS = MyDB.OpenRecordset("Table1", dbOpenDynaset)
-
Set MyRS2 = MyDB.OpenRecordset("Table2", dbOpenDynaset)
-
-
Do While Not MyRS.EOF
-
If MyRS![Field1] <> MyRS2![Field1] Then
-
Debug.Print MyRS![Field1] & " <> " & MyRS2![Field1]
-
End If
-
-
If MyRS![Field2] <> MyRS2![Field2] Then
-
Debug.Print MyRS![Field2] & " <> " & MyRS2![Field2]
-
End If
-
-
If MyRS![Field3] <> MyRS2![Field3] Then
-
Debug.Print MyRS![Field3] & " <> " & MyRS2![Field3]
-
End If
-
-
If MyRS![Field4] <> MyRS2![Field4] Then
-
Debug.Print MyRS![Field4] & " <> " & MyRS2![Field4]
-
End If
-
MyRS.MoveNext
-
MyRS2.MoveNext
-
Loop
-
-
MyRS.Close
-
MyRS2.Close
explaining my query.......... ......
first consider both of the tables have same number of fields and name of fields are same as well.
Let say I have 10 fields and I want to compare 10 fields of table 1 from table 2.
As far as values in the fields are concerned, they can be any number like 1, 5000, 32,2,0 etc.
I mean comparing like if one of the fields has value 1 in table one and in table 2, the same field is having value 2 instead of 1, so I want to find out only these changes.
Result can be shown in any way
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Odd-R. |
last post by:
I have to lists, A and B, that may, or may not be equal. If they are not
identical, I want the output to be three new lists, X,Y and Z where X has
all the elements that are in A, but not in B, and Y contains all the
elements that are B but not in A. Z will then have the elements that are
in both A and B.
One way of doing this is of course to iterate throug the lists and compare
each of the element, but is there a more efficient way?
...
|
by: osmethod |
last post by:
Hello,
I have read many articles about comparing tables, like - loops, delete
queries, appending to temp table with index etc
Problem: 2 tables T1 & T2. Data is suppposed to be the same in both
tables but i need to check that this is so. (Maybe a user deleted a
row in one table only or changed a value in a field!). The tables have
no unique index.
|
by: laxmiuk |
last post by:
I've original version of a table called PMM (Product Material Master).
Thro' a web interface, user can change that table contents. Once
changed, i need to raise an ECN (Engineering CHange Note) specifying
what changes happened to original PMM table whether rows are deleted,
new rows are added or existing rows are modified etc. I've both old and
new version of PMM tables.
The difference between two PMM tables are captured in a third table...
|
by: windandwaves |
last post by:
Hi Guys
I want to find out if two tables are identical (e.g. same fields, same
indexes, etc....). Not the data, but the table structure itself.
Is there a smart way to do that?
Cheers
|
by: Reg Rat |
last post by:
Hello all,
I'm led to believe that the .Net framework offers intelligent string
comparison such that é follows e in an alphabetic sort rather than appearing
after z, for example. Does this mean that there is a mechanism for comparing
strings that may or may not have accents and having them shown as identical
(e.g. comparing Herve with Hèrvé would show a match). Ideally, this should
be culture neutral as I will not have knowledge of which...
| |
by: MORALBAROMETER |
last post by:
Hi all,
I have two tables that are not link. But their content are
interrelated. I want to find out what is in one table that is not in
the other and vice-versa. how can archieve this in c# or within the
database.
thanks
|
by: Kristaps |
last post by:
Hi everyone!
I have some questions, maybe someone can help me...
I write script for table comparing, but it works wery slovly. There is the script, can anyone give some tip how can I make this process faster and if it is possible in VB.
The idea is to compare two tables and if there is some distinction, then is written in third table. Some tables contains more than 200 000 rows and each row contain approximatelly 30 parameeters (columns)....
|
by: Franck |
last post by:
how come unchanged always true even if data changed
This code come from my saving button:
============================================
DataSet ds1 = new DataSet();
DataSet ds2 = new DataSet();
DataSet ds3 = new DataSet();
//Static Dataset which contain values when my form load
|
by: gillianbrooks91 |
last post by:
Forgive me for asking this question, I've trawled through nearly every
available post on this subject that I can find for a few weeks now but
nothing quite points me in the right direction.
I'm quite new to trying to mess around with VB and ADO within MS
Access and have realised the steep learning curve I have, but, I want
to try and solve this problem quickly and was wondering if anyone
would help me out??
I want to be able to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |