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!

Why does what appears to be a simple append query is pasting 5 duplicate rows?

TheresAlwaysAWay

Programmer
Joined
Mar 15, 2016
Messages
147
Location
US
I have what is to the eye a simple append query. I'm posting a picture of the query structure with the message, and a picture of the table content.

The SQL for the query is::

Code:
INSERT INTO CVInsQuotes ( CVID, Company, Quote )

SELECT [Forms]![CommercialVehicles]![CVID] AS CVID, 'National General' AS Company, [Forms]![CommercialVehicles]![NatGen] AS Quote

FROM CVReferrals;

I don't see why it's trying to create 5 duplicate rows. Hoping someone can assist.
 

Attachments

  • screenshot1.jpg
    screenshot1.jpg
    140.7 KB · Views: 8
  • Screenshot.jpg
    Screenshot.jpg
    350.9 KB · Views: 8
How many records are there in the table CVReferrals? It would look as if you are creating one instance for each. Perhaps you need a 'WHERE' clause to limit the list generated.
 
Why are you even selecting from CVReferrals?

It seems to me you want to insert one record, that's done with a simple INSERT ... VALUES:

Code:
INSERT INTO CVInsQuotes ( CVID, Company, Quote ) VALUES ([Forms]![CommercialVehicles]![CVID], 'National General', [Forms]![CommercialVehicles]![NatGen])

When you select from another table you always get as many records as are in there, no matter if you sepcify or don't specify fields from that table or not. And the only way to reduce the number of records appended would be by a WHERE clause, as Drainie said.

It doesn't make sense to query from CVReferrals when you don't set any target column of CVInsQuotes to something coming a column of CVReferrals, though, does it? So even if you could add a where clause that filters only 1 record of CVReferrals, that would work but would still be pointless as you'd say "take this record, but instead of taking any values from it take these values." Well, there#s the simplest of INSERT-SQL queries fro that, the one specifiying your set of values. They seem to come from a form, not from another table, don't they? Or am I misunderstanding your intent?
 
Last edited:
How many records are there in the table CVReferrals? It would look as if you are creating one instance for each. Perhaps you need a 'WHERE' clause to limit the list generated.
None. It is a brand new table but I'm just creating for the first time
 

Part and Inventory Search

Sponsor

Back
Top