Deleting objects in another DB

  • Thread starter Thread starter Mota
  • Start date Start date
M

Mota

Hello;
How to Delete or Rename a table from another Database (other than the DB im
coding in),while im in the CurrentDB?
Thank you for your help.
 
Ok,then how to delete a table from inside this db.Can i use
DoCmd.DeleteObject and be sure that tables in db will be deleted,rather than
a table with the same name in currentDB?
Thank you for ur help.
 
No, if you use DeleteObject, it will delete from currentdb (or possibly
codedb if you're running the code from an add-in). If you want to delete a
table or a query, Arvin's suggestion will work...

Set db = OpenDatabase("path to database")

db.TableDefs.Delete "some table"
db.QueryDefs.Delete "some query"


HOWEVER, if you're trying to delete a form or any other object other than
tables or queries, you would need to instantiate another Application object
and use automation, i.e.,

Set app = New Access.Application

app.OpenCurrentDatabase "path to database here"

app.Docmd.DeleteObject [objType], [objName]

app.Quit
 
Thank you for ur help.

Paul Overway said:
No, if you use DeleteObject, it will delete from currentdb (or possibly
codedb if you're running the code from an add-in). If you want to delete a
table or a query, Arvin's suggestion will work...

Set db = OpenDatabase("path to database")

db.TableDefs.Delete "some table"
db.QueryDefs.Delete "some query"


HOWEVER, if you're trying to delete a form or any other object other than
tables or queries, you would need to instantiate another Application object
and use automation, i.e.,

Set app = New Access.Application

app.OpenCurrentDatabase "path to database here"

app.Docmd.DeleteObject [objType], [objName]

app.Quit

--
Paul Overway
Logico Solutions
http://www.logico-solutions.com


Mota said:
Ok,then how to delete a table from inside this db.Can i use
DoCmd.DeleteObject and be sure that tables in db will be deleted,rather
than
a table with the same name in currentDB?
Thank you for ur help.
 
Back
Top