Database engine could not lock table

dimitri

Registered User.
Local time
Today, 07:38
Joined
Oct 9, 2012
Messages
18
Hello,

I am using Access 2007. There are multiple tabs on the Main page
Tab 1, has a subform where "Table A" data is to be displayed.
Tab 2, has a subform where "Table B" data is displayed
Tab 3, I have a button which executes these commands

DoCmd.RunSQL ("DELETE * FROM Table A")
DoCmd.OpenQuery "Query 1"

Query 1 selects data from Table B and inserts into table A

At the line "DoCmd.OpenQuery "Query 1" error is thrown as

Run-time error '3211':

"Database engine could not lock Table A because its already in use by another person or process"

Tried closing the DB and opening but still no avail.

Any suggestions is much appreciated.

Thanks
 
Try to put in a "DoEvents" between DoCmd.RunSQL ("DELETE * FROM Table A") and DoCmd.OpenQuery "Query 1"

Code:
DoCmd.RunSQL ("DELETE * FROM Table A")
DoEvents
DoCmd.OpenQuery "Query 1"
 
JHB,

That did not work.. Any other suggestions.:)
 
Put in a Me.Refresh or Me.Requery before the DoCmd.
What if you comment out the DoCmd.RunSQL ("DELETE * FROM Table A")?
Only to se where the problem lays.
If you are able to run DoCmd.OpenQuery "Query 1", then put in a breakpoint in your code and remove the comment and se if you then are able to run both DoCmd.

Show also the SQL-string of "Query 1".

Or you could post the database with sample data, (Zip
 
Put in a Me.Refresh or Me.Requery before the DoCmd.
What if you comment out the DoCmd.RunSQL ("DELETE * FROM Table A")?
Only to se where the problem lays.
If you are able to run DoCmd.OpenQuery "Query 1", then put in a breakpoint in your code and remove the comment and se if you then are able to run both DoCmd.

Show also the SQL-string of "Query 1".

Or you could post the database with sample data, (Zip

Me.Refresh worked for me!! Thanks so much!
 

Users who are viewing this thread

Back
Top Bottom