Hi, i've posted the problem previously in the Excel programming forum but i've since worked out what the problem is and I think its more of an access issue than an excel one, so please forgive the repost.

Essentialy what i'm doing is using automation to program excel from within access; i'm creating a querytable in excel that connects back to the access database that is running the code that is creating the querytable! Hope that makes sense!

Anyway the problem i'm having is that sometimes the querytable refresh fails with a general ODBC error, i've worked out that this is due to the connection being refused as the database is effectively locked due to me being in it whilst running this process!

in troubleshooting I managed to narrow down the problem to this error message:

title: ODBC Minrosoft Access Driver login Failed
Body: The database has been placed in a state by user 'Admin' on machine 'my computer' that prevents it from being opened or locked.

So the question is how do I get around this? it works sometimes so i'm guessing there must be some programatic way to put the database into a state where the connection will not be refused.

here is the code snippet:

Please Login or Register  to view this content.

The error occurs at the refresh method line, and just to be clear there is nothing wrong with the code, it works perfectly, I just need some way to stop the connection being refused.

Any help appreciated.