Repost of VB Run-time error '3211'

T

Tony Girgenti

I'm reposting this because i tried deleteing the table manually and
recreating it manually. It works OK after that, but when i try it again, it
gives the error again. There are four tables, but it only happens on the
"ITEMS" table.

I'm trying to execute the following code and i am getting this error:

"Run-time error '3211'; The database engine could not lock table 'Items'
becuase it is already in use by another person or process".

This code is being executed in AccessXP using an ODBC connection to a server
DB. I'm not sure exactly which statement it is giving the error on.
All other computers were turned off and the one computer was restarted, but
we still get the error. The table is not being used by a form.

Any help would be greatly appreciated.

Tony

============================================================================
=================================
CurrentDb.Execute "DROP TABLE Items"

DoCmd.TransferDatabase acImport, "ODBC Database", _

"ODBC;DSN=DEMO2ENG;ArrayFetchOn=1;ArrayBufferSize=8;DBQ=DEMO2ENG;OpenMode=0;
DecimalSymbol=.;;TABLE=Items", _
acTable, "Items", "Items"
CurrentDb.Execute "CREATE UNIQUE INDEX ItemNumIdx ON Items (ItemNumber)"
 
T

TC

How can you not be sure what statement is giving the error? Add a msgbox
before each statement :)

Two ideas - neither of which might be the cause, but they would be easy to
check:

(1) Is "items" a reserved word in Access? (I do not have it here to check.)
If so, try [Items].

(2) Try caching the currentdb reference: (You should really do this anyway)

dim db as database
set db = currentdb()
' do things with db, not currentdb().
set db = nothing

HTH,
TC


Tony Girgenti said:
I'm reposting this because i tried deleteing the table manually and
recreating it manually. It works OK after that, but when i try it again, it
gives the error again. There are four tables, but it only happens on the
"ITEMS" table.

I'm trying to execute the following code and i am getting this error:

"Run-time error '3211'; The database engine could not lock table 'Items'
becuase it is already in use by another person or process".

This code is being executed in AccessXP using an ODBC connection to a server
DB. I'm not sure exactly which statement it is giving the error on.
All other computers were turned off and the one computer was restarted, but
we still get the error. The table is not being used by a form.

Any help would be greatly appreciated.

Tony

============================================================================
=================================
CurrentDb.Execute "DROP TABLE Items"

DoCmd.TransferDatabase acImport, "ODBC Database", _

"ODBC;DSN=DEMO2ENG;ArrayFetchOn=1;ArrayBufferSize=8;DBQ=DEMO2ENG;OpenMode=0;
DecimalSymbol=.;;TABLE=Items", _
acTable, "Items", "Items"
CurrentDb.Execute "CREATE UNIQUE INDEX ItemNumIdx ON Items
(ItemNumber)"
 
G

Gary Walter

Tony Girgenti said:
I'm reposting this because i tried deleteing the table manually and
recreating it manually. It works OK after that, but when i try it again, it
gives the error again. There are four tables, but it only happens on the
"ITEMS" table.

I'm trying to execute the following code and i am getting this error:

"Run-time error '3211'; The database engine could not lock table 'Items'
becuase it is already in use by another person or process".

This code is being executed in AccessXP using an ODBC connection to a server
DB. I'm not sure exactly which statement it is giving the error on.
All other computers were turned off and the one computer was restarted, but
we still get the error. The table is not being used by a form.

Any help would be greatly appreciated.

Tony

============================================================================
=================================
CurrentDb.Execute "DROP TABLE Items"

DoCmd.TransferDatabase acImport, "ODBC Database", _

"ODBC;DSN=DEMO2ENG;ArrayFetchOn=1;ArrayBufferSize=8;DBQ=DEMO2ENG;OpenMode=0;
DecimalSymbol=.;;TABLE=Items", _
acTable, "Items", "Items"
CurrentDb.Execute "CREATE UNIQUE INDEX ItemNumIdx ON Items (ItemNumber)"
Hi Tony,

I am assuming you did not want to *link* to
the SQL table?

Would you mind changing your local table
name to "tblItems" then try the following:

'----------------------------
Dim strSQL As String

Debug.Print "About to delete table."
CurrentDb.Execute "DROP TABLE tblItems", dbFailOnError
Debug.Print "Have deleted table."

strSQL = "SELECT Items.* INTO tblItems " _
& "FROM Items IN '' [ODBC;DSN=DEMO2ENG;DATABASE=];"
Debug.Print "Make table query: " & vbCrLf & strSQL

CurrentDb.Execute strSQL, dbFailOnError
Debug.Print "Have executed make table."

Debug.Print "About to create index."
strSQL = "CREATE UNIQUE INDEX ItemNumIdx ON tblItems (ItemNumber);"
CurrentDb.Execute strSQL, dbFailOnError
Debug.Print "Have created index."
'------------------------------

{from tip provided by John Viescas}
To see what needs to go in between the brackets,
temporarily link to remote table "Items," then in
Immediate Window type the following:

?CurrentDb.Tabledefs("Items").Connect

Place whatever this returns inside the brackets,
then delete link to "Items."

Please respond back if I have misunderstood.

Good luck,

Gary Walter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top