How insert new record in a table if there is no perfect match of 10 fields

I have a temporary table that contains several fields.  But I want to add records to a separate table named tblVendors using just 10 of the fields in the temporary table.  The code will have to loop through the records in the temporary table and insert a new record into tblVendors BUT ONLY if the same combination of field data does not already exist.  What would this VBA code look like?  

In other words if any one field is different that a record already in tblVendors, go ahead and create the new record.  But if all 10 of them are an exact match, do not create the new record

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You don't need code at all.  Create a compound unique index on the ten fields (lucky for you because 10 is the maximum that Jet/ACE support)  SQL Server is more flexible.

To make a compound index,
1. Open the table in design view
2. Open the indexes dialog
3. On the first completely empty line,give the index a name (I use UniqueIDX), select the first field, and choose the unique option
4. For fields 2-10, just enter the field name on a separate line.
5. At the end, the index will contain 10 lines.  The first will have a name but the name field will be empty on all the rest.  This tells Access that all the columns together will make up the unique index.

Then run an append query that selects the data from table1 to table2.  When the append query finishes, you'll get a message that tells you that x records were appended and y records were not appended due to key violations, and z records were not appended due to rule violations.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SteveL13Author Commented:
WOW!  Perfect.  The only other think I had to do was make UniqueIDX = Yes.  Thank you.
and choose the unique option
That's what I said :)
SteveL13Author Commented:
I understand now.   Thanks again.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.