Solved

Add record to a table from other table

Posted on 2007-03-25
4
273 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
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 …

920 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now