vba - Access Queries in Sub Database -


i know how open secondary database master database, how can switch "focus" secondary database , scan through table names see if table exists in database, if delete it?

this how open database seems check database running code in, not secondary database opened.

set qd = currentdb.querydefs("exec_dead") set ws = dbengine(0) set db = ws.opendatabase("c:\test\testing.mdb") on error resumse next docmd.deleteobject actable = acdefault, "late payments today" 

you need create access.application variable can interact instance of access.

dim db dao.database dim tbl dao.tabledef dim accdb access.application  set accdb = new access.application accdb.opencurrentdatabase "c:\test\testing.mdb", false  each tbl in accdb.currentdb.tabledefs     if tbl.name = "the name of table want delete"         accdb.docmd.deleteobject actable, tbl.name     end if next  accdb.closecurrentdatabase set accdb = nothing 

Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -