code needed to check if value from one table can be found in another table (1 Viewer)

illusionek

Registered User.
Local time
Today, 06:52
Joined
Dec 31, 2013
Messages
92
Hello

I have VBA code that imports Excel files from a specific folder into table A and then appends some data from table A to table B.

I need now to amend this code so after importing into table A it would check if values from column 1 in table A are in column 1 in table C and if not then stop the code and display an error message, ideally showing which values are missing but this is optional.


Any help please?
 

plog

Banishment Pending
Local time
Today, 08:52
Joined
May 11, 2011
Messages
11,653
The best way would be to set up a query to compare the two tables (A & C). It would be based A and you would LEFT JOIN (http://www.w3schools.com/sql/sql_join_left.asp) C and then you would have criteria to show only records where a required field in C was NULL. Then in your VBA you would do a DCount into that query to see if any records were in that query, if so, stop your code and open the query.
 

illusionek

Registered User.
Local time
Today, 06:52
Joined
Dec 31, 2013
Messages
92
Hi

I just tried but it does not work. I actually checked all three joins and neither of them provides desire result. If I use LEFT JOIN then I just get all records from A and matchin from C but it does not provide info whats the difference if any. So if I do DCount then I would always have some records in that query. Unless I am missing a point here?
 

plog

Banishment Pending
Local time
Today, 08:52
Joined
May 11, 2011
Messages
11,653
Not the point, your missing a detail. Did you apply the NULL criteria I mentioned?
 

illusionek

Registered User.
Local time
Today, 06:52
Joined
Dec 31, 2013
Messages
92
Of course you are right. Schoolboy error.

Thanks a lot for all your help.
 

Users who are viewing this thread

Top Bottom