Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to query database based on a list values?

Status
Not open for further replies.

TTThio

Programmer
May 3, 2001
185
0
0
US
Hi,

I need help to built a query based on a list.
I have 2 worksheets,
the first one contains some list of datas.
The second one will be populated with data from database which is not in the first worksheet.

I tried to create both queries directly in the code, such as query data where 'Account' NOT IN subquery. It took so long that I finally got a message of 'Execution Failed'.
So, now, I'm trying to first query data resulting in the list, put in the worksheet, but then
How to query data in the database which is not in the list (worksheet).

Thanks ahead.
 
I think what you need to do is:
Create a recordset of the data in the database.
For each record in a recordset, use VLOOKUP to try and find it in the first worksheet. If it isnt there, add it to the second worksheet.

HTH

M.
 
Hi,
You can either build YourList to use in this syntax:
Code:
"WHERE  ACCOUNT NOT IN (" + YourList + ") "
or you can perform multiple SQLs, substituting each list value and taking each resultset and appending the results. Skip,
metzgsk@voughtaircraft.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top