Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Copy table through code.

74 views
Skip to first unread message

Bita

unread,
Oct 8, 2000, 3:00:00 AM10/8/00
to
Dear Newsgroup,

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.


jon

unread,
Oct 8, 2000, 3:00:00 AM10/8/00
to
If you want to manipulate objects in another database, then you will
probably end up using Automation to open the second database, and then you
can use this new instance of Access to make the required changes:

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...

0 new messages