DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: copy a few fields from a table to annother

  1. #1
    Join Date
    Oct 2004
    Location
    Portugal
    Posts
    48

    copy a few fields from a table to annother

    Hi:

    This is a little piece off code who create a new table in a DB and then copy all the records to the new table...the code work,but just copy 2 recordsets and the table fichas have 20 recordsets.

    Anybody now Why this happens?


    Code:

    Private Sub Copiarregisto_Click()


    Set tdf = DB.CreateTableDef("fichas1")

    With tdf

    .Fields.Append .CreateField("anilha", dbText, 15)
    .Fields.Append .CreateField("Sexo", dbText, 10)
    .Fields.Append .CreateField("Dt_Nasc", dbText, 50)
    .Fields.Append .CreateField("Espécie", dbText, 40)
    .Fields.Append .CreateField("Raça", dbText, 50)
    .Fields.Append .CreateField("Côr", dbText, 100)
    .Fields.Append .CreateField("Portação", dbText, 50)
    .Fields.Append .CreateField("Factores", dbText, 20)


    End With
    DB.TableDefs.Append tdf

    Dim SQLstr As String
    SQLstr = "INSERT INTO fichas1(anilha,Sexo,Dt_Nasc,Espécie,Raça,Côr,Portação) " & _
    "SELECT fichas.anilha, fichas.Sexo, fichas.Dt_Nasc, fichas.Espécie, fichas.Raça, fichas.Côr, fichas.Portação FROM fichas"


    DB.Execute SQLstr


    End Sub


    Thanks

  2. #2
    Join Date
    Dec 2003
    Posts
    2,750
    I don't see any problem with the code.

    Try adding the dbFailOnError argument to your Execute statement to see if an error is occurring during the Insert. If you don't include the argument an error will not be triggered if there is a problem executing the SQL statement.

    DB.Execute SQLstr, dbFailOnError
    Paul
    ~~~~
    Microsoft MVP (Visual Basic)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center