Select

D

DS

Hoe do you you select from one table (Table1) certain records and INSERT
into (Table2) using SQL.

Thanks
DS
 
D

Dirk Goldgar

DS said:
Hoe do you you select from one table (Table1) certain records and
INSERT into (Table2) using SQL.

Use an append query. See the help file. book "Microsoft Jet SQL
Reference", subheading "Data Manipulation Language", topic "INSERT INTO
Statement". Or type "append query" in the online help, which will give
you a topic on how to do it with the query designer; make such a query
and then switch it to SQL View to see the SQL it generates.
 
G

ge2001 via AccessMonster.com

DS said:
Hoe do you you select from one table (Table1) certain records and INSERT
into (Table2) using SQL.

Thanks
DS

Hi DS !

In our example, destination Table2 has 3 Fields: Name, Address, Fone
and our source Table1 has several fields, but 3 on our focus: CustomerName,
CustomerAddress and CustomerFone.

The names must match with the destination table - thus...

Criteria = "INSERT INTO Table2 " _
& "SELECT CustomerName AS Name, CustomerAddress AS Address, CustomerFone
AS Fone " _
& "FROM Table1 " _
& "WHERE " & Condition & " " _
& "ORDER BY CustomerName;"
DoCmd.RunSQL Criteria ' Execute the SQL comand

That is faster than any procedure with recordsets, in VBA.

Good luck...
 
Top