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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

inserting SQL in criteria section of a make table query

Status
Not open for further replies.
Jun 30, 2004
9
US
Hello. I have a make table query where I am selecting records from a table based on values I have put in to the criteria section of the query. This works fine. There is one field on the table "user", that I want to select from based on values in another table "tblUserids". Can I do that in the criteria section?
The field is 7 bytes long and has values such as JB83160, JW21330 in it. I have a table called tblUserids that contains the userids that are valid such as JB83160, JW21330. I want to select records from the first table based on the values in tblUserids

The question is - Can you insert SQL in the criteria section of a make table query

Or

Is there a way to point to the values of the other table in the criteria section of a make table query?

If not, what other way would you reccommend I do this? Any help would be greatly appreciated. Thanks.
 
This worked for me:

SELECT x.[Item Id] INTO NewTable
FROM x
WHERE (((y.[Item Id]) In (Select [item id] from [y] where [item id] = "84912" )));
 
Thanks for the code. I found out how to do it within the make table query itself. I just had to add the tblUserids table to the available tables and then right clicked on the criteria box. Then select Build. Then double click on the table tblUserids and the code is generated. Thanks for the response.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top