Solved

Not IN

Posted on 2013-01-01
5
249 Views
Last Modified: 2013-01-01
Experts, I have the below APPEND query.  
I am trying to APPEND to tblConsortium where tblAgreements_thisPrj.AgtID is NOT IN tblConsortium.AgtID

There are records that should be APPENDED but when I run it there are 0 records to be APPENDED.  

What do you think is missing?
thanks.

INSERT INTO tblConsortium ( AgtID )
SELECT tblAgreements_thisPrj.AgtID
FROM tblAgreements_thisPrj
WHERE (((tblAgreements_thisPrj.AgtID) Not In (SELECT [tblConsortium].[AgtID] FROM [tblConsortium])));


APPEND_NOTIN
0
Comment
Question by:pdvsa
5 Comments
 
LVL 17

Expert Comment

by:Kent Dyer
ID: 38735214
I think this is what you are looking for:
INSERT INTO tblConsortium ( AgtID )
WHERE
(SELECT tblAgreements_thisPrj.AgtID
FROM tblAgreements_thisPrj
WHERE ((
(tblAgreements_thisPrj.AgtID)
 Not In (SELECT [tblConsortium].[AgtID] FROM [tblConsortium])
))
);

Open in new window


HTH,

Kent
0
 

Author Comment

by:pdvsa
ID: 38735223
Kent:  thanks for the response. I do get a syntax and it highlights the WHERE right below the INSERT.  what do you think now?
0
 
LVL 75
ID: 38735259
How are you executing this Append query? Have you turned off SetWarnings ? Because if so, it may be masking a error that is occurring.  Comment out any DoCmd.SetWarnings False and see if an error is occurring.

mx
0
 
LVL 26

Accepted Solution

by:
jerryb30 earned 500 total points
ID: 38735265
INSERT INTO tblConsortium ( agtID )
SELECT tblConsortium.agtID
FROM tblAgreements_thisPrj LEFT JOIN tblConsortium ON tblAgreements_thisPrj.agtID = tblConsortium.agtID
WHERE (((tblConsortium.agtID) Is Null));
0
 

Author Closing Comment

by:pdvsa
ID: 38735280
Jerry:  that was it.  I remember that Is Null trick now.  I guess that method is better than NOT IN.  I will write that down.  

thank you
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question