I have been asked to copy and rename a table using code.
I was able to do so in one database by using the docmd
copyobject and rename methods.
My problem is that I can not do this from one database
for another. Now I have a database that is split into tables
and the rest of database objects are in another database
, and now that I want to use copyobject method,
in the source object to be copied,
I do not know how to specify a table in the other database,
I also do not know how to rename table which is in another
database.
If you know the syntax, or any other methods that may work
PLEASE let me know, I really need your help.
Thank you.
Sub sRenameInDatabase(strDBName As String, strOldObjectName As String,
strNewObjectName As String, bytObjectType As Byte)
Dim accObj As New Access.Application
accObj.OpenCurrentDatabase strDBName
accObj.DoCmd.Rename strNewObjectName, bytObjectType, strOldObjectName
accObj.CloseCurrentDatabase
End Sub
and then call this sub like:
Call sRenameInDatabase("C:\Whatever.mdb","tblOldName","tblNewName",acTable)
You should be able to use similar procedures to copy and delete objects as
well. You will probably want to have some error handling in there - just in
case the object doesn't already exist.
--
Jon
http://www.applecore99.freeserve.co.uk
Bita <bi...@emirates.net.ae> wrote in message
news:39E08185...@emirates.net.ae...