473,406 Members | 2,710 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Table lock problem while trying to delete

Hey guys, I am getting a "database cant lock table "blah" because it is already in use by another person or process" while trying to delete, then re-populate it. This table is viewed in a subform (CSD appender embedded) in datasheet view, and I have been changing the recordsource of the form to another table, making any changes that are required, then setting it back. This is a technique which I have been using successfully throughout the code within this form but has started causing a problem as I have added a new peice of code.

I have checked the recordset properties in both the parent and child form objects, and both of them are set to different tables. I have also checked the recordsets.count property is 0 to ensure that I have closed any recordsets that I may have open on the table.

It seems like a system setting which I cannot access is still set somewhere and I am unsure how to change this.

Code:
Private Sub pull_matches()
Dim display As String
DoCmd.SetWarnings False
frm_view = "matches"

For Each varItm In Show.ItemsSelected
display = display & "[zzappend].[" & Show.ItemData(varItm) & "], "
Next varItm
display = left(display, Len(display) - 2)
Forms![csd appender].Form![csd appender embedded].Form.RecordSource = "zzappend"

If Table_exists("zzappend_temp") Then
DoCmd.DeleteObject acTable, "zzappend_temp" 'This is where the error occurs
End If

sql = "SELECT " & display & ", [zzappend].ID, zzappend.[change to] INTO zzappend_temp FROM zzappend WHERE (((zzappend.shv1) IN (SELECT [shv1] FROM [zzappend] as tmp GROUP BY [shv1], [" & Cmbpostcode.Value & "] HAVING count(*)>1 AND " & Cmbpostcode.Value & " = [zzappend]." & Cmbpostcode.Value & "))) ORDER BY zzappend.shv1, zzappend.[" & Cmbpostcode.Value & "];"
DoCmd.RunSQL (sql)

sql = "ALTER TABLE zzappend_temp ADD changed bit"
DoCmd.RunSQL (sql)

Forms![csd appender].Form![csd appender embedded].Form.RecordSource = "zzappend_temp"
DoCmd.SetWarnings True

End Sub
Jan 17 '08 #1
1 3526
PianoMan64
374 Expert 256MB
The reason that you're getting that error, is because the table is never closed, especially if it is in the same current Database. That's the reason that you're getting that error.

If it was something that when you openned another instance of that up, and made sure that the table is not currently being view by anyone including yourself, then you would be able to delete the record, but since you have it open in the current instance of the database, you can't do that, you simply can change the data within it, and even the structure, but not delete the table all together.

Hope that helps,

Joe P.
Jan 20 '08 #2

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

Similar topics

6
by: gdekhayser | last post by:
To any and all; I have a very large table (16Mil+ records), for which I want to delete about 8 Million records. There are a few indexes on this table. Is there a way that I can run either a...
2
by: G.W. Lucas | last post by:
I apologize if this is a RTFM question, but I have not been able to find a definitive answer elsewhere. Does a "REINDEX TABLE" lock the table while it is working? Can applications write data to...
3
by: Joachim Klassen | last post by:
Hi all, first apologies if this question looks the same as another one I recently posted - its a different thing but for the same szenario:-). We are having performance problems when...
4
by: deko | last post by:
I'm trying to delete a table with db.execute DROP TABLE tempTable I've tried first clearing the RecordSource of the forms that use tempTable like this: Me!RecordSource = "" But it does...
8
by: Roy Padgett | last post by:
I have a combo box where users select the customer name and can either go to the customer's info or open a list of the customer's orders. The RowSource for the combo box was a simple pass-through...
4
by: deko | last post by:
I'm trying to import an Excel Spreadsheet into an Access Table but sometimes things get buttered up if the spreadsheet does not have the right columns. So I want to drop the Access table and...
9
by: BillCo | last post by:
I have a function which clears out a temporary table and then fills it with values from a recordset. One of the table fields is indexed with no duplicates. Very rarely - almost enough to ignore it...
2
by: John Bokma | last post by:
I am quite new to MS SQL, and I want to read rows from a todo table, and when a row has been processed, I want to delete that row. Ages ago in MySQL I would probably have locked the table,...
5
by: Roger | last post by:
I am doing some mass update on DB2 8.2 FP10 (say 400 to 500 rows on a 5000 row table) with just one commit. So this is taking lot of exclusive row locks as expected. When I run a select on the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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
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...
0
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.