looking into another db for an object (1 Viewer)

Roni Sutton

Registered User.
Local time
Today, 19:37
Joined
Oct 18, 1999
Messages
68
I have created code that will export an object from the current db to another db using the docmd.copyobject command (TO db name is input by the user). I want to check the other db to ensure that the object does not currently exist before I export it. If it does exist, I want to delete it from the TO db prior to exporting. Do I have to connect to the other database using DAO or something like it or is there a command such as docmd.copyobject that will allow me to look in the other db for the object and/or delete it if necessary?

Thanks,
Roni
 

MHM

Registered User.
Local time
Today, 19:37
Joined
Mar 15, 2000
Messages
101
I'd look into the other db with DAO:

set db=Workspaces(0).OpenDatabase("FileName")
on error goto tableNotFound
if isnull(db.TableDefs("TableNameToSearchFor").Fields(0)) then
' empty
endif
MsgBox "Table does exist."
Exit sub

tableNotFound:
MsgBox "Table doesn't exist."
Exit sub


Mic
 

Roni Sutton

Registered User.
Local time
Today, 19:37
Joined
Oct 18, 1999
Messages
68
Will this also work with form, query, report and module defs? I thought about this, but I didn't see some of the other definitions in the list. Thanks for your help!

Roni
 

Users who are viewing this thread

Top Bottom