473,503 Members | 2,114 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to unlock a table?

17 New Member
I am using the code below,
In one of the sections i am running a query to delete all records in the db,
then a short while later i import the records intothe


DoCmd.OpenQuery "qryDelConfirmationTable", acViewNormal

DoCmd.TransferText acImportFixed, "alCouponSpecsImport2", "tblALConfirmFile", Filename

After that i attempt to build a new table wiht the current information, this returns a runtime error 3211, saying the database could not lock the table because it is in use.
I have read up on 3211 and the "solutions" did not help, i get the same thing. I tried closing the connection and redefining the connection same thing.
What am i doing wrong?



Expand|Select|Wrap|Line Numbers
  1. Private Sub CmdXLBrowse_Click()
  2.  
  3. Dim Filename As String
  4. Dim db As Database
  5. Set db = CurrentDb()
  6. ' do things with db, not currentdb().
  7. Set db = Nothing
  8.  
  9.     'Me.txtXLFIle = ""
  10.     Me.txtXLFIle.Value = FindFile(Me.txtXLFIle.Value, "Please Select a Text File", "Text Files", "*.tx?")
  11.     'Me.txtXLFIle.Value = FindFile(Me.txtXLFIle.Value, "Please Select an Excel File", "Excel Files", "*.xl?")
  12.  
  13.     Filename = Nz(Me.txtXLFIle.Value, "1")
  14.  
  15.     'Clean Up
  16.     'DoCmd.SetWarnings False
  17.     DoCmd.OpenQuery "qryDelConfirmationTable", acViewNormal
  18.     Debug.Print "Old Confirmations Erased"
  19.     DoCmd.OpenQuery "qryDelCouponItemsTable", acViewNormal
  20.     Debug.Print "Old Vouchers Deleted"
  21.  
  22.     DoCmd.TransferText acImportFixed, "alCouponSpecsImport2", "tblALConfirmFile", Filename
  23.     'Drop Table deletes from database
  24.     'CurrentDb.Execute "Drop table tblALConfirmFile"
  25.  
  26.     DoCmd.OpenQuery "qryALCreateCouponDataFile", acViewNormal
  27.     DoCmd.OpenForm "frmALCoupon 7-24-08", acNormal
  28.     'DoCmd.SetWarnings True
  29.  
  30. On Error GoTo MyErrorCheck
  31. MyErrorCheck:
  32.     If Err.Number = 3011 Then
  33.     ' Do something here
  34.     MsgBox "Please Try Again", vbOKOnly
  35.     Resume
  36.     End If
  37.  
  38.     If Err.Number = 7874 Then
  39.     ' Do something here
  40.     Resume
  41.     End If
  42.  
  43.     If Left(Trim(txtXLFIle), 1) = "'" Then
  44.     ' comment line, skip it
  45.     End If
  46.  
  47. End Sub
  48.  
Jul 25 '08 #1
1 16083
nico5038
3,080 Recognized Expert Specialist
Two remarks:
1) Better to use:
currentdb.execute ("qryDeleteConfirmations")
this won't open the query and keep the table locked, but just delete the rows.
2) When there's a relation between Confirmation and CouponItems, be sure to remove the "children" before the "parent" when no Cascading delete has been defined as a relation.

Nic;o)
Jul 27 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
4500
by: John | last post by:
I've got multiple threads and processes that write to same file. Before writing all threads / processes first lock part of file and then write to file. If one thread / process locks file, another...
1
1277
by: Shlomo Anglister | last post by:
Hi, How can I unlock stdio streams? There used to be an unlock API, what happened to it? I will appreciate any kind of help. Thanks, Shlomo
1
3185
by: deko | last post by:
Is there a way to unlock a table so a subroutine can complete? frmMain!frm0 has got a lock on a table I need to do stuff with. Error Number 3211: The database engine could not lock table...
2
3859
by: Unlock | last post by:
Greetings, Any expert able to help me to unlock the database at http://www.generate.netfirms.com/cgi-bin/to.cgi?l=res04 You will need to download the database which I have compressed into a...
3
4918
by: Pat | last post by:
Anyone know how I can unlock a table I created in MSAccess by the user Admin? I am using WindowsXP. Cheers Pat
4
7236
by: accesstribe | last post by:
Folks, I have Access db, but whenever I try to open it and view design of tables, forms, etc, ie, when I double click on icon then instead of opening it in MS Access it opens as application, first...
1
1372
by: M.C | last post by:
Following is a snap-shot of compiler created code when using UEM, use /Fx: struct __EventCriticalSectionStub { void Lock() {} void Unlock() {} }; ....
2
1332
by: Mitch | last post by:
Would anyone have a routine kicking around that would take a users email address and convert it into a string of numbers to use as an unlock code? I am writing an application and would like it to...
1
6901
by: leucine | last post by:
I have a table which do not allow me to modify it. Error message is "A query or form bound to the table is open, you may not have permission to open this table to design view, or another user has...
0
7205
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7093
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7348
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7006
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7467
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5021
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4685
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
744
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.