Results 1 to 5 of 5

Thread: Add a table to new database from existing one

Hybrid View

  1. #1
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Add a table to new database from existing one

    you're not doing what you think you're doing... you can't pull up an existing table def, and then simply append it to a new database... it still belongs to the old database....

    you have to create a new table def object, loop through the fields of the old table, copy them over (by creating new ColumnDefs and appending them to the new table) ... THEN you can append your new table to the second database.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  2. #2

    Thread Starter
    New Member
    Join Date
    Jan 2011
    Posts
    14

    Re: Add a table to new database from existing one

    Ok, I am trying the following code. (TableDef is not recognized.) I am getting error "Arguments are of the wrong type or in conflict".

    Dim sFileName As String
    Dim catThisDb As ADOX.Catalog
    Dim catSource As ADOdb.Connection
    Set catSource = New ADOdb.Connection
    Set catThisDb = New ADOX.Catalog
    catThisDb.ActiveConnection = CurrentProject.Connection
    Dim tblNew As ADOX.Table
    Set tbl = New ADOX.Table
    Set tbl = catThisDb.Tables("Yields")
    Set tblNew = New ADOX.Table
    tblNew.Name = "Yields"

    For Each col In tbl.Columns
    tblNew.Columns.Append (col)
    Next col
    catSource.Open "Provider=Microsoft.JET.OLEDB.4.0;Data Source= C:\Clients\WF.mdb"

    Set tblNew = catSource.Tables("Yields")
    catSource.Tables.Append tblNew

    Thanks,
    -D

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width