Saturday, February 25, 2012

Repost of VB Run-time error '3211'

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;ArrayBu
fferSize=8;DBQ=DEMO2ENG;OpenMode=0;
DecimalSymbol=.;;TABLE=Items", _
acTable, "Items", "Items"
CurrentDb.Execute "CREATE UNIQUE INDEX ItemNumIdx ON Items (ItemNumber)"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" <antoniongirgenti@.comcast.net> wrote in message
news:OeD2wd04DHA.2772@.TK2MSFTNGP09.phx.gbl...
quote:

> 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
quote:

> 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
quote:

> 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
quote:

> we still get the error. The table is not being used by a form.
> Any help would be greatly appreciated.
> Tony
>

========================================
====================================[QUO
TE]
> =================================
> CurrentDb.Execute "DROP TABLE Items"
> DoCmd.TransferDatabase acImport, "ODBC Database", _
>[/QUOTE]
" ODBC;DSN=DEMO2ENG;ArrayFetchOn=1;ArrayBu
fferSize=8;DBQ=DEMO2ENG;OpenMode=0;[QUOT
E]
> DecimalSymbol=.;;TABLE=Items", _
> acTable, "Items", "Items"
> CurrentDb.Execute "CREATE UNIQUE INDEX ItemNumIdx ON Items[/QUOTE]
(ItemNumber)"|||"Tony Girgenti" <antoniongirgenti@.comcast.net> wrote in message
news:OeD2wd04DHA.2772@.TK2MSFTNGP09.phx.gbl...
quote:

> 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 serv
er
> 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, bu
t
> 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;ArrayBu
fferSize=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|||Tony,
It is not considered to be polite to cross-post the same question to several
news groups, because of this your message is ignored by many skilled news
group readers. And then again resending the same question over and over
again is even more rude.
Regards,
"Tony Girgenti" <antoniongirgenti@.comcast.net> wrote in message
news:OeD2wd04DHA.2772@.TK2MSFTNGP09.phx.gbl...
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;ArrayBu
fferSize=8;DBQ=DEMO2ENG;OpenMode=0;
DecimalSymbol=.;;TABLE=Items", _
acTable, "Items", "Items"
CurrentDb.Execute "CREATE UNIQUE INDEX ItemNumIdx ON Items (ItemNumber)"

No comments:

Post a Comment