Compare values in in two tables fields (1 Viewer)

mcdhappy80

Registered User.
Local time
Today, 10:58
Joined
Jun 22, 2009
Messages
347
I need to create a procedure which will be able to check if some value in field of one table doesn't exist in the field with the same name and data type in other table.
I'm using two RS-s method to loop trough the data of both tables.
Anny suggestions?
Thank You
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 01:58
Joined
Aug 30, 2003
Messages
36,127
Have you tried the unmatched query wizard?
 

mcdhappy80

Registered User.
Local time
Today, 10:58
Joined
Jun 22, 2009
Messages
347
Have you tried the unmatched query wizard?

No, but after some more reading on the net I've solved the problem with the either left or right join on the tables.

But in spite of that, I am really curious what programming logic could be applied to solve this problem in VBA?
 

ghudson

Registered User.
Local time
Today, 04:58
Joined
Jun 8, 2002
Messages
6,195
you could use a Dcount() function to test if the value exists in another table
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 01:58
Joined
Aug 30, 2003
Messages
36,127
No, but after some more reading on the net I've solved the problem with the either left or right join on the tables.

But in spite of that, I am really curious what programming logic could be applied to solve this problem in VBA?

The join is how the unmatched query works. The easy answer is to open a recordset on an unmatched query. If you really want some sort of brute force code solution, you probably already have it; two recordsets, or as ghudson suggested, one recordset loop with an DCount within to check the second table. Neither would be anywhere near as efficient as the query.
 

mcdhappy80

Registered User.
Local time
Today, 10:58
Joined
Jun 22, 2009
Messages
347
The join is how the unmatched query works. The easy answer is to open a recordset on an unmatched query. If you really want some sort of brute force code solution, you probably already have it; two recordsets, or as ghudson suggested, one recordset loop with an DCount within to check the second table. Neither would be anywhere near as efficient as the query.
Or I could use unmatched query (with one of three possible joins) as record set source (query definition) and then check the values in it in both tables.
For now, I edited the tables manually (from within that query) and it worked like a charm :D
Thank You for all suggestions.
Consider this question closed, for now ;)
Cheers
 

Users who are viewing this thread

Top Bottom