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

Need help with Insert unmatched query 1

Status
Not open for further replies.

DougP

MIS
Joined
Dec 13, 1999
Messages
5,985
Location
US
I want to find any project not in one table and add it to a third table. Then allow the user to check a box next to the ones to import. The following SQL gives an error "Duplicate output Destination Project Number”. If I remove Project Number from the left of the QBE grid then it does not insert the Project Number but leaves it blank. No good. I need the have the project number later.

Code:
INSERT INTO ChooseTheseToImport ( [Project Number], Service, [Number], [Building Name], [Date], [Project Number] )
SELECT [ChainOfCustody Old].[Project Number], [ChainOfCustody Old].Service, [ChainOfCustody Old].Number, [ChainOfCustody Old].[Building Name], [ChainOfCustody Old].Date, ChainOfCustody.[Project Number]
FROM [ChainOfCustody Old] LEFT JOIN ChainOfCustody ON [ChainOfCustody Old].[Project Number] = ChainOfCustody.[Project Number]
WHERE (((ChainOfCustody.[Project Number]) Is Null));

DougP
 
You are trying to insert two diff things into the same field ProjectNumber - can't do that.

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244. Basics at
 
No just trying to insert the project number.
When I use the QBE grid that's what it creates. its an unmatched query so it add the [Project Number]) Is Null) column. It work fine if I run it without the insert line.

DougP
 
You have to take the 2nd "PROJECT NUMBER" out (Yes, Access throws it in there because it's trying to help, but you MUST take it out - the one in the APPEND TO row on the far Right above the criteria IS NULL.

Code:
INSERT INTO ChooseTheseToImport ( [Project Number], Service, [Number], [Building Name], [Date] )
SELECT [ChainOfCustody Old].[Project Number], [ChainOfCustody Old].Service, [ChainOfCustody Old].Number, [ChainOfCustody Old].[Building Name], [ChainOfCustody Old].Date
FROM [ChainOfCustody Old] LEFT JOIN ChainOfCustody ON [ChainOfCustody Old].[Project Number] = ChainOfCustody.[Project Number]
WHERE (((ChainOfCustody.[Project Number]) Is Null));

I built your tables and fixed this and it works fine.

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244. Basics at
 
OMG it works!
Thank you so much!!!
have a star ;)
_/\_
\ /
/ \


DougP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top