Run Query Based on Value From Another Table

crhodus

Registered User.
Local time
Today, 12:49
Joined
Mar 16, 2001
Messages
257
I'm trying to create a query that will dump data from table COMPANY_T, into another table NAMED tblCompany1, if any of the companies from COMPANY_T have their company number recorded in table tblCompNum1.

Can someone tell me what I'm doing wrong? Thanks!

SELECT [Company_T].[COMPANY_NUMBER], [Company_T].[INDIVIDUAL], [Company_T].[LAST_UPDATED] INTO tblCompany1
FROM Company_T
WHERE ((([Company_T].[COMPANY_NUMBER]) In ([tblCompNum1].[COMPANY_NUMBER])));
 
Your are Using the SELECT INTO and that creates a new table. You probaly want to use the UPDATE statement. This way you can us your criteria on the table because it won't erase any records

HTH
 
Actually, I want it to replace these records every time it runs. The records in the table are only temporary records.

Regardless, thanks for your comments!

[This message has been edited by crhodus (edited 09-11-2001).]
 
Thanks. I tried doing what you recomended, but I ended up adding the following line of code:

WHERE COMPANY_NUMBER IN
(SELECT [tblCompNum1].[COMPANY_NUMBER] FROM tblCompNum1);

This seems to have worked. Thanks again!
 

Users who are viewing this thread

Back
Top Bottom