WHERE IN Query with two recordsets in Access VBA
Posted
by Henry Owens
on Stack Overflow
See other posts from Stack Overflow
or by Henry Owens
Published on 2010-04-22T07:57:30Z
Indexed on
2010/04/22
8:03 UTC
Read the original article
Hit count: 242
Hi All,
My first post here, so i hope this is the right area. I am currently trying to compare 2 recordsets, one of which has come from an Excel named range, and the other from a table in the Access database. The code for each is:
Set existingUserIDs = db.OpenRecordset("SELECT Username FROM UserData")
Set IDsToImport = exceldb.OpenRecordset("SELECT Username FROM Named_Range")
The problem is that I would like to somehow compare these two recordsets, without looping (there is a very large number of records). Is there any way to do a join or similar on these recordsets?
I can not do a join before creating the recordsets, due to the fact that one is coming from Excel, and the other from Access, so they are two different DAO databases.
The end goal is that I will choose only the usernames that do not already exist in the access table to be imported (so in an SQL query, it would be a NOT IN(table)).
Thanks for any assistance you can lend!
Regards, Bricky.
© Stack Overflow or respective owner