473,406 Members | 2,619 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.

How to delete records from MS Access table

Hi. I am having difficulty deleting records from my ‘Holding Fee’ Table. The names used in the access code below are the table names and field names used in the database. When I try to run the delete query I am presented with the following ‘Microsoft Office Access’ Information Popup message:
‘Specify the table containing the records you want to delete’.
I have searched the internet for an answer and played with the code but I have not been able to effect the deletion of the records. The archive table contains the ‘three field values’ which together supply a ‘unique reference’ to those records which need to be deleted from the ‘Holding Fee’ table; ‘Location ID’, ‘Room Number’ and ‘Date Of Arrival’. (The departing occupant records have already been appended to the ‘Holding Fee Archive’ so, for now, I am using the ‘Holding Fee Archive’ table as a source for the field criterion, ‘values’ which need to be met. I thought a table may be a more reliable source than a query). I need syntax which will ‘FIND’ and ‘DELETE’ records on the basis of WHERE ‘field 1 in table A = value in field 1 of table B’ and ‘field 2 of table A = value in field 2 of table B’ and ‘field 3 in table A = value of field 3 in Table B’ DELETE THESE RECORDS. I tried the following but it did not work.
Expand|Select|Wrap|Line Numbers
  1. DELETE tblHoldingFee.[Loc_ID HF], tblHoldingFee.[RM_No HF], tblHoldingFee.DO_Arrival
  2. FROM tblHoldingFee, tblArchive_HoldingFee
  3. WHERE (([tblHoldingFee].[Loc_ID HF] Like [tblArchive_HoldingFee.Loc_ID HF]) AND ([tblHoldingFee].[RM_No HF] Like [tblArchive_HoldingFee].[RM_No HF]) AND ([tblHoldingFee].[DO_Arrival] Like [tblArchive_HoldingFee.DO_Arrival]));
I am using Office 2003 on Windows XP. I am the database administrator, no user level security has been set up and the database is not read only. Sorry, I am NOT a whiz with SQL. Anyone out there who can help me; it would be much appreciated. Thank you
Jul 26 '10 #1

✓ answered by NeoPa

You can only delete from an updatable recordset (See Reasons for a Query to be Non-Updatable). Your recordset consists of a Cartesian Product of two discrete tables. Certainly not updatable.

From your description I suspect you want something like :
Expand|Select|Wrap|Line Numbers
  1. DELETE tHF.*
  2. FROM   tblHoldingFee AS tHF INNER JOIN
  3.        tblArchive_HoldingFee AS tAHF
  4.   ON   ([tHF].[Loc_ID HF]=[tAHF].[Loc_ID HF])
  5.  AND   ([tHF].[RM_No HF]=[tAHF].[RM_No HF])
  6.  AND   ([tHF].[DO_Arrival]=[tAHF].[DO_Arrival])
Welcome to Bytes!

7 3579
ADezii
8,834 Expert 8TB
@Martin Lee
This can be done relatively easily with VBA Code utilizing Nested Recordset Loops, but I'll wait and see if someone comes up with a SQL-based solution.
Jul 26 '10 #2
NeoPa
32,556 Expert Mod 16PB
You can only delete from an updatable recordset (See Reasons for a Query to be Non-Updatable). Your recordset consists of a Cartesian Product of two discrete tables. Certainly not updatable.

From your description I suspect you want something like :
Expand|Select|Wrap|Line Numbers
  1. DELETE tHF.*
  2. FROM   tblHoldingFee AS tHF INNER JOIN
  3.        tblArchive_HoldingFee AS tAHF
  4.   ON   ([tHF].[Loc_ID HF]=[tAHF].[Loc_ID HF])
  5.  AND   ([tHF].[RM_No HF]=[tAHF].[RM_No HF])
  6.  AND   ([tHF].[DO_Arrival]=[tAHF].[DO_Arrival])
Welcome to Bytes!
Jul 26 '10 #3
ADezii
8,834 Expert 8TB
@NeoPa
Hello NeoPa. We're not talking about a Cartesian Product but two, Nested, Independent, Recordsets. The Nested loops will test for equality on the three Fields fora each Record in Table A against all Records in Table B. Should a match exist at an iteration, use the DELETE Method of the Recordset Object to remove the Record in Table A.
Jul 27 '10 #4
NeoPa
32,556 Expert Mod 16PB
My comments were referring to the SQL posted by the OP, rather than what I was recommending ADezii.
Jul 27 '10 #5
ADezii
8,834 Expert 8TB
@NeoPa
Sorry NeoPa, off on a Tangent again!
Jul 27 '10 #6
@NeoPa
Thank you NeoPa and Adezii for reading my long enquiry and for kindly responding. The solution offered by NeoPa worked Splendidly. Having searched for an answer for some hours prior to posting on bytes; receiving a solution so quickly was wonderful. Many, Many thanks to you both.
Jul 27 '10 #7
NeoPa
32,556 Expert Mod 16PB
You're very welcome Martin, and I'm glad that suggestion hit the spot :)
Jul 28 '10 #8

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

Similar topics

6
by: Paul T. Rong | last post by:
Dear all, Here is my problem: There is a table "products" in my access database, since some of the products are out of date and stopped manufacture, I would like to delete those PRODUCTS from...
2
by: Robin | last post by:
I have a main table that I need to delete records that arn't referenced in another. Query says I cannot delete. If I remove the reference query all deletes ok. Hope there is a way around this ?...
1
by: tgbnagaraj | last post by:
Hi how to delete records which has same id from 2 tables. In oracle we can use delete from t1,t2 where t1.id=1 and t1.id=t2.id
1
by: davea | last post by:
Hi I have a command button that when clicked deletes certain records from a subform based on an application number being equal. It deletes all records with the same applciation number as...
6
by: satish mullapudi | last post by:
Hi All, I am getting strange situation. These r the steps I have followed: 1. Created an EMPLOYEE table with around 14 fields & 688038 records. (so a large table indeed). 2. Tried to delete all...
4
by: felicia | last post by:
Hi All, Below is my code to delete records: adodcAllEntries.Recordset.MoveFirst Do While (adodcAllEntries.Recordset.EOF = False) If adodcAllEntries.Recordset.Fields(0) = selected_id Then...
2
by: =?Utf-8?B?SWJyYWhpbS4=?= | last post by:
Hello, I have a client c# application from which I want to Add/Edit/Delete & list records by connecting to Web Service. HOw can I write classes & methods in Web service projet that will : ...
1
by: elbatz | last post by:
Hi! Does anyone know the code of how to delete records in access using excel as reference. example: Delete * FROM table1 WHERE table1.ID=excelfile.ID ? Thanks
9
by: MEGDZIA | last post by:
Could you please advise whether it is possible to delete records in suborm. When I highlight whole record it won't let me do it. I've chcecked all properties and it should allow to delete...
6
by: kstevens | last post by:
I have tables setup with a main table for information and a subtable that records the "multiple" records for the main record. I have written a query to go in and find Null or "" values to delete...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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...

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.