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
Post a Comment