|
-
Jun 1st, 2011, 11:35 AM
#1
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
-
Jun 1st, 2011, 02:30 PM
#2
Thread Starter
New Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|