Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / September 2006

Tip: Looking for answers? Try searching our database.

Comparing datasheets

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ray Cacciatore - 29 Sep 2006 20:12 GMT
I have a main form with two subforms (both in datasheet view). Both have the
same columns. I need to compare the data from the two datasheets to catch any
differences between them. The problem is that these subforms can have
hundreds of rows and there are 14 columns in each subform.

To give a bit more detail. The left subform has data that will be imported,
the right subform has data that already was imported. If there is no
difference between them, then I don't import. So I need a way to find if they
are different. Is there a way to do this? Even programmatically.

Ray
Tom Wickerath - 29 Sep 2006 22:55 GMT
Hi Ray,

You might want to consider using Total Access Detective, by FMS:
   http://www.fmsinc.com/products/detective/index.html

It can be used to find differences in the data in tables. I don't know if
this product allows programmatic control; that would be a question for the
vendor, FMS.

Tom Wickerath
Microsoft Access MVP

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________

> I have a main form with two subforms (both in datasheet view). Both have the
> same columns. I need to compare the data from the two datasheets to catch any
[quoted text clipped - 7 lines]
>
> Ray
Granny Spitz - 30 Sep 2006 16:58 GMT
> I need to compare the data from the two datasheets to catch any
> differences between them.

Hon, you don't need to spend 200 bucks on a software tool.  You can write
your own query and check the results of the query to determine what the
differences are.  You need to use a full outer join on the primary key.  Jet
doesn't support full outer joins, but you can create the equivalent by using
a left outer join and a right outer join, and then using a union of the two.
For this example, we can use the following table structures (although queries
can be used as the data sets, too):

CREATE TABLE tblEquipment
 (SerialNum Text (8) NOT NULL,
 Nomenclature Text (50) NOT NULL,
 Location Text (255) NOT NULL,
 CONSTRAINT PrimaryKey Primary Key (SerialNum));

CREATE TABLE tblNewEquip
 (SerialNum Text (8) NOT NULL,
 Nomenclature Text (50) NOT NULL,
 Location Text (255) NOT NULL,
 CONSTRAINT PrimaryKey Primary Key (SerialNum));

tblEquipment is the existing table and tblNewEquip is the data set to be
imported if there are any differences.  Running the following query will
result in only the different records being returned:

SELECT Eq.SerialNum, NE.SerialNum,
 Eq.Nomenclature, NE.Nomenclature,
 Eq.Location, NE.Location
FROM tblEquipment AS Eq LEFT JOIN tblNewEquip AS NE
 ON Eq.SerialNum = NE.SerialNum
WHERE (ISNULL(NE.SerialNum)) OR
 (Eq.Nomenclature <> NE.Nomenclature) OR
 (Eq.Location <> NE.Location)
UNION
SELECT Eq.SerialNum, NE.SerialNum,
 Eq.Nomenclature, NE.Nomenclature,
 Eq.Location, NE.Location
FROM tblEquipment AS Eq RIGHT JOIN tblNewEquip AS NE
 ON Eq.SerialNum = NE.SerialNum
WHERE (ISNULL(Eq.SerialNum)) OR
 (Eq.Nomenclature <> NE.Nomenclature) OR
 (Eq.Location <> NE.Location);

Programmatically (or with a separate query) you can count the number of
records returned by this query.  If no records are returned, then both tables
are identical, and you don't need to import the new data set.  If records are
returned, then here's how to read the results:

1)  Eq.SerialNum is NULL:  a new record is to be imported from the import
table (tblNewEquip).
2)  NE.SerialNum is NULL:  the imported records don't contain this record
that's in the existing table (tblEquipment).
3)  Both Eq.SerialNum and NE.SerialNum have values:  the other matching
columns have to be checked to see which ones don't have matching values, eg.
Eq.Nomenclature <> NE.Nomenclature, etc.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.