[AccessD] Rename & Copy Tables In Current Database Using ADO

Gustav Brock Gustav at cactus.dk
Fri Apr 21 10:02:25 CDT 2006


Hi Paul 

Rename is quite easy:

Function RenameTable()
  
  Dim cat As New ADOX.Catalog
  Dim tbl As ADOX.Table
  
  cat.ActiveConnection = CurrentProject.Connection
  On Error Resume Next
  Set tbl = cat.Tables("schednew")
  If Err.Number = 0 Then
    tbl.Name = "schedold"
  End If
  
  Set tbl = Nothing
  Set cat = Nothing

End Function

For copying you could use the code from Drew to read the table schema and create a copy.

/gustav

>>> paul.hartland at fsmail.net 21-04-2006 16:34:05 >>>
To all,
Gustav helped me a little bit earlier (thanks a lot Gustav) in detecting if a table exists and deleting it if it does.  But I can't seem to find anything on copying and renaming tables using ADO, if anyone has any sample code or could point me in the right direction I would be grateful.
Thank you for any help in advance.
Paul Hartland





More information about the AccessD mailing list