Copy a Table to another Table 
Author Message
 Copy a Table to another Table

Question, (VB6 +Acces97)

Is it possible to copy an acces table (e.g. TABLE1) with about 5000 records
to a new table (e.g. TABLE2 which is empty).

The way I do it now is:

I open TABLE1 and select all records.=>

Data1.databasename="Database.mdb"
Data1.recorssettype=0
Data1.recordsource="TABLE1"
Data1.refresh

Data2.databasename="Database.mdb"       'Same database as Data1
Data2.recordsettype= 0
Data2.recordsource="NEW"            '    This is an empty table with the
same structure as TABLE1

with Data1.recordset

        .movelast
        .movefirst

Do while not .EOF

Data2.recordset.addnew

Data2.recordset.fields(0)= .Fields(0)
Data2.recordset.fields(1)= .Fields(1)
Data2.recordset.fields(2)= .Fields(2)
Data2.recordset.fields(3)= .Fields(3)
Data2.recordset.fields(4)= .Fields(4)
Data2.recordset.fields(5)= .Fields(5)
Data2.recordset.fields(6)= .Fields(6)

Data2.recordset.Update

.Movenext

Loop

End With

This way is working, only the speed is to slow for me.
Is it possible to copy table Table1 direct to table NEW without opening
Tabl1 and do it record by record.

I hope someone can give me an answer

Thanks

Gerwin Spijkerboer




Tue, 23 Sep 2003 16:47:41 GMT  
 Copy a Table to another Table
Use SQL

INSERT INTO Table1 SELECT * FROM Table2

or

INSERT INTO Table1(field1, field2, field3) SELECT field1, field2, field3
FROM Table2

This should knock your time down to about a second.



Tue, 23 Sep 2003 19:37:44 GMT  
 Copy a Table to another Table
On Fri, 6 Apr 2001 07:37:44 -0400, "Hot Rod"

Quote:

>Use SQL

>INSERT INTO Table1 SELECT * FROM Table2

>or

>INSERT INTO Table1(field1, field2, field3) SELECT field1, field2, field3
>FROM Table2

>This should knock your time down to about a second.

in Access, i think it should be

Select * Into Table2 From Table1



Wed, 24 Sep 2003 11:30:17 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Copy a Table to another Table

2. copy dbase table to access table

3. Copy Dbase table to Access Table

4. Copy fields from record in table A to record in table B using VBA

5. Copy Record from Table 1 to Table 2 - Acc97 - VBA

6. HowTo Copy a Recordset from a Table to an identically structured table

7. Copying the structure of a table to a new table

8. Copying Table text to tables

9. Copying table definition to create new table

10. Help Help Need to copy a field from one table into another table

11. MS Access DB - Copy Table A from Database A to Table A Database B

12. SQL and Copying Table to Table

 

 
Powered by phpBB® Forum Software