paul.hartland at fsmail.net
paul.hartland at fsmail.net
Fri Apr 21 10:15:06 CDT 2006
Thanks yet again gustav but I used this method instead, can't believe I couldn't remember this (having a Friday moment today I think):
DoCmd.CopyObject , "schednew" & "_" & Format(Now(), "DDMMYYYY") & "_" & Format(Time(), "HHMMSS"), acTable, "schednew"
Makes a copy with a new name.
Thanks again.
Paul Hartland
Message Received: Apr 21 2006, 04:04 PM
From: "Gustav Brock"
To: accessd at databaseadvisors.com
Cc:
Subject: Re: [AccessD] Rename & Copy Tables In Current Database Using ADO
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
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com