Copy Field or Table 
Author Message
 Copy Field or Table

Hello!

I would like to copy a field from one Table to another with VBCode. It is
important that the data in this field gets also copied. It would also help
me if you can tell me how to copy the whole table. If somebody knows how to
realize this then answer me, please.

nice greatings,

Markus



Sat, 06 Dec 2003 14:08:19 GMT  
 Copy Field or Table
On Tue, 19 Jun 2001 08:08:19 +0200, "Markus Pandur"

Quote:

>Hello!

>I would like to copy a field from one Table to another with VBCode. It is
>important that the data in this field gets also copied. It would also help
>me if you can tell me how to copy the whole table. If somebody knows how to
>realize this then answer me, please.

>nice greatings,

>Markus

Markus, we need more information.

Are you copying the field into a field in an existing row in Table 2,
or do you want to add it into a new row?

If it is in an existing row, how will you locate this row?

If it is to go into a new row, what do we put into the rest of the
fields in this new row? Do you in fact want to copy the whole row from
Table 1 to Table 2, not just one field?

The simplest thing is if you describe exactly what you are trying to
do, then we can give you a specific answer.

Copying the whole table is easy.

If both tables are in the one database, just open an ADO connection,
say Cn, and use this line of code:

    Cn.execute "INSERT INTO Table2 SELECT * FROM Table1"

If table2 is in a different database, lets say "c:\data\Db2.mdb", then
use

    Cn.execute "INSERT INTO Table2 IN  c:\data\Db2.mdb " & _
                             "SELECT * FROM Table1"

Richard.



Sat, 06 Dec 2003 14:58:01 GMT  
 Copy Field or Table
I want copy a existing "column(=field in german)1" from "database1" to an
existing (or not) - What is easier? - "colomn2" in "database2". I would
prefer to realize this with DAO but if it isnt possible  I take what i get.
Please be patient! I'm a beginner and my mother tongue is german, thats why
it is sometimes not so easy for me to explain what i mean.

Thank you,

Markus



Quote:
> On Tue, 19 Jun 2001 08:08:19 +0200, "Markus Pandur"

> >Hello!

> >I would like to copy a field from one Table to another with VBCode. It is
> >important that the data in this field gets also copied. It would also
help
> >me if you can tell me how to copy the whole table. If somebody knows how
to
> >realize this then answer me, please.

> >nice greatings,

> >Markus

> Markus, we need more information.

> Are you copying the field into a field in an existing row in Table 2,
> or do you want to add it into a new row?

> If it is in an existing row, how will you locate this row?

> If it is to go into a new row, what do we put into the rest of the
> fields in this new row? Do you in fact want to copy the whole row from
> Table 1 to Table 2, not just one field?

> The simplest thing is if you describe exactly what you are trying to
> do, then we can give you a specific answer.

> Copying the whole table is easy.

> If both tables are in the one database, just open an ADO connection,
> say Cn, and use this line of code:

>     Cn.execute "INSERT INTO Table2 SELECT * FROM Table1"

> If table2 is in a different database, lets say "c:\data\Db2.mdb", then
> use

>     Cn.execute "INSERT INTO Table2 IN  c:\data\Db2.mdb " & _
>                              "SELECT * FROM Table1"

> Richard.



Sun, 07 Dec 2003 04:42:53 GMT  
 Copy Field or Table
Markus,

Please see this KB article. You can use 'SELECT INTO' statement to realize this functionality

http://support.microsoft.com/support/kb/articles/q200/4/27.asp

Since the sample delivered in Q200427 is created by C/C++, I rewrote it in VB as follows.  

Dim cnn As ADODB.Connection
Dim sSQL As String  

Set cnn = New ADODB.Connection
cnn.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Northwind.mdb;"  
cnn.Open  

' [Products] is the SOURCE while [Products_Test] is the DESTINATION
sSQL = "SELECT * INTO [Products_Test] from [C:\Northwind.mdb].[Products]"  
cnn.Execute sSQL
cnn.Close
Set cnn = Nothing

Peter



Mon, 08 Dec 2003 14:36:52 GMT  
 Copy Field or Table
On Tue, 19 Jun 2001 22:42:53 +0200, "Markus Pandur"

Quote:

>I want copy a existing "column(=field in german)1" from "database1" to an
>existing (or not) - What is easier? - "colomn2" in "database2". I would
>prefer to realize this with DAO but if it isnt possible  I take what i get.
>Please be patient! I'm a beginner and my mother tongue is german, thats why
>it is sometimes not so easy for me to explain what i mean.

>Thank you,

>Markus

Markus,

Is this what you are trying to do?

Table1:      Product_Ref
                  Product_Name
                  Product_Cost

in Database 1

Table2:     Product_Ref
                 Product_Name

in database 2

Do you wnat to copy the Product_Cost column to Table2 in database 2?

It is probably important to know what kind od database you are using.
With SQL Server, you can modify a database using SQL.  With Access,
most of these SQL commands do not work, and you should use the DAO
Create-type commands (eg CreateField), or ADOX if you want to use ADO.

To copy the whole of Table1 into another database using Access
datbases, you can use a SQL statement like

"INSERT INTO Table1 IN c:\data\database2.mdb SELECT * FROM Table1"

while connecting to Database1.

Richard.

Quote:



>> On Tue, 19 Jun 2001 08:08:19 +0200, "Markus Pandur"

>> >Hello!

>> >I would like to copy a field from one Table to another with VBCode. It is
>> >important that the data in this field gets also copied. It would also
>help
>> >me if you can tell me how to copy the whole table. If somebody knows how
>to
>> >realize this then answer me, please.

>> >nice greatings,

>> >Markus

>> Markus, we need more information.

>> Are you copying the field into a field in an existing row in Table 2,
>> or do you want to add it into a new row?

>> If it is in an existing row, how will you locate this row?

>> If it is to go into a new row, what do we put into the rest of the
>> fields in this new row? Do you in fact want to copy the whole row from
>> Table 1 to Table 2, not just one field?

>> The simplest thing is if you describe exactly what you are trying to
>> do, then we can give you a specific answer.

>> Copying the whole table is easy.

>> If both tables are in the one database, just open an ADO connection,
>> say Cn, and use this line of code:

>>     Cn.execute "INSERT INTO Table2 SELECT * FROM Table1"

>> If table2 is in a different database, lets say "c:\data\Db2.mdb", then
>> use

>>     Cn.execute "INSERT INTO Table2 IN  c:\data\Db2.mdb " & _
>>                              "SELECT * FROM Table1"

>> Richard.



Mon, 08 Dec 2003 16:34:37 GMT  
 
 [ 5 post ] 

 Relevant Pages 

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

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

3. Copy fields to a different table

4. Copying fields from one table to another

5. help copying field from 1 table to another

6. changing field prop's or copying data to another table

7. copy of word tables to rtf-fields

8. Copying some fields from a table to another

9. How to copy two same field type and length into new table

10. How to copy two same field type and length into new table

11. Create new fields in a table based off of fields in another table

12. Create new field in existing table exactly like field in second table

 

 
Powered by phpBB® Forum Software