Solved

Add record to a table from other table

Posted on 2007-03-25
4
289 Views
Last Modified: 2008-02-01
I have this two tables , products and new products, in new products i enter the new products that i receive , this products don't exist in products table, i want to run a sql query that add all this record to the product table.
Any ideas

0
Comment
Question by:cano63
4 Comments
 
LVL 9

Expert Comment

by:TheSloath
ID: 18789606
Create a new query and add your 'New Products' table.
Change the query's type on the Query Menu to 'Append'.
Add the fields from the 'New Products' table you wish to add to the Products tale, and select the field in the Products table you wish each field from the New Products table to be added to.
0
 
LVL 38

Accepted Solution

by:
puppydogbuddy earned 125 total points
ID: 18789624
Dim sSQL As String

sSQL = "INSERT INTO tblProducts "
sSQL =  sSQL & "Select * "
sSQL =  sSQL &  "From [tblNewProducts] ;"

Current db.Execute sSQL, dbFailOnError
0
 
LVL 9

Expert Comment

by:dbeneit
ID: 18790052
If you want to insert those products than they are new and not insert olds:
INSERT INTO  products (Productid, [ other  list fields])
select NEWp.Productid,  NEWp.[other  list fields]   from NEWproducts NEWp  left join products OLDp on NEWp.Productid=OLDp.Productid
WHERE OLDp.Productid IS NULL
0
 
LVL 44

Expert Comment

by:GRayL
ID: 18790067
I guess I have to ask, why two tables?  If you had a boolean field named KeepYN (default=No), on a regular basis, you could query all the No records and 'decide' which ones to 'Keep'.  Just another way of looking at it.
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Suggested Solutions

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

777 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