Hello loungers...

I have a routine that imports data into Access, and part of this routine involves creating ad-hoc tables to store the imported info and then run a INSERT INTO on pre-defined master tables. this all works. unfortunately, when i try to do something like

dbs.Execute "DROP TABLE <table name>"
DoCmd.DeleteObject acTable, "<table name>"
Access says it can't access the locked table in the first case and it can't lock the table in the second case. Not sure exactly how to get around this. I've tried closing the DAO object for the Access db and then running the code or doing a new dao.Database with TableDefs, both of which are done once the INSERT INTO has been completed. Inserting transaction being/commit didn't help either, but I may not be doing that correctly. i don't need to do a rollback anyway so I'd prefer not to add a transaction scenario into the mix. But whatever will help I will do.

I've done this thing before in other dbs and this is the first time i've run across this issue.

Thanks in advance!

Problem solved: I converted the sub to a procedure, and broke the routine for deleting the tables into a separate function. attach code to a button:

Call <function Import>
Call <function delete tables>