473,569 Members | 2,984 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Delete records in a query by referencing another

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 ?
Query as follows:
DELETE Items.*, Items.SupplierC ode, Items.UpdatedDa teTime, [Check if
Existing Quote Number exists before delete].ItemNumber
FROM [Check if Existing Quote Number exists before delete] RIGHT JOIN Items
ON [Check if Existing Quote Number exists before delete].ItemNumber =
Items.ItemNumbe r
WHERE (((Items.Suppli erCode)=[Forms]![frmImport]![cmbSuppliers]) AND
((Items.Updated DateTime)<>[Forms]![frmImport]![DTNOW1]) AND (([Check if
Existing Quote Number exists before delete].ItemNumber) Is Null));

Are using this below query in a form and works fine except deletes all
records. I need to reference the other query so some items are not deleted.
Hope someone can help ?

DoCmd.RunSQL " DELETE Items.*, Items.SupplierC ode, Items.UpdatedDa teTime
FROM Suppliers INNER JOIN Items ON Suppliers.Suppl ierCode =
Items.SupplierC ode WHERE
(((Items.Suppli erCode)=[Forms]![frmImport]![cmbSuppliers]) AND
((Items.Updated DateTime)<>[Forms]![frmImport]![DTNOW1]));"

Many thanks
Rob
Apr 11 '06 #1
2 2011
Robin schreef:
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 ?
Query as follows:
DELETE Items.*, Items.SupplierC ode, Items.UpdatedDa teTime, [Check if


Try DELETE DISTINCTROW Items.* FROM ....

Apr 11 '06 #2
Thankyou Kaniest ... for your help .. all works ok now..
Rob

"kaniest" <ka*****@invali d.invalid> wrote in message
news:44******** *************** @news.xs4all.nl ...
Robin schreef:
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 ?
Query as follows:
DELETE Items.*, Items.SupplierC ode, Items.UpdatedDa teTime, [Check if


Try DELETE DISTINCTROW Items.* FROM ....

Apr 12 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2339
by: alloowishus | last post by:
I have some records that will not delete, whenever I run a delete statement in the Query analyzer, it never completes the statement, and I am only deleting one record at a time. Can anyone tell me why a record wouldn't delete?
10
17769
by: D. Dante Lorenso | last post by:
I'd like to run a clean up command on my tables to eliminate rows that I'm no longer using in the database. I want to do something like this: DELETE FROM tablename WHERE IS_REFERENCED_BY_FOREIGN_KEY IS FALSE; Does anyone know how something like this could be done in PostgreSQL? I know I can search all the tables that
14
8069
by: Darin | last post by:
I have a table that I want to delete specific records from based on data in other tables. I'm more familiar with Access '97, but am now using 2003, but the database is in 2000 format. In '97, I think I could have easily done this using joins, but I kept getting "could not delete from specified tables" errors. Some google searching has...
8
2778
by: paulwilliamsonremove | last post by:
Hi, Using Access 2003. I am trying to delete records from one table/query ("qryHistoryPersonIDs") if they don't exist in another table ("qryDonations"). But the SQL syntax I came up with is taking forever or locking up Access 2003. What am I doing wrong?
2
8822
by: Cornelius Buschka | last post by:
Hi, we saw the following problem: We deleted all rows from a table B referencing table A (~500000 records). No problem, but the following try to delete all records from table A (~180000) lead to a "never ending" statement. We found out, that vacuuming table B after delete did the trick. It seems to us the database has to do scan thru...
16
17523
by: Sam | last post by:
Hi, As I loop through a dataview's records, I delete datarow based on a condition. However I don't want to commit those deletions until the loop ends. With a datatable, i would just set row.delete() and call AcceptChanges when the loop ends. But how can I do that with a dataview ? Thank you
13
2838
by: forbes | last post by:
Hi, I have a user that used the Query Wizard to create a query in Access. Now she claims that her master table is missing all the data that was excluded from the query. Can you create anything other than a select query using the Wizard? What do you think happened to her data? I am working remotely until Friday, so I can't get down to her...
5
4131
by: Bob Bridges | last post by:
Start with two tables, parent records in one and child records in the other, a one-to-many relationship. Create a select statement joining the two. Display the query in datasheet mode. When I delete a row, only the child record is deleted from the source tables; the parent record is still there...which is what I wanted. Now display fields...
10
2675
by: nickvans | last post by:
Hello everyone, I'm fairly new to VBA and MS Access (I'm using 2003) but my issue seems like a pretty straight forward one. I would like to delete all records found in one table from another one. I have code which grabs values from a list box (which has as its source "tblNewModPart") then uses them in a Make-Table query which creates a table...
0
7703
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7619
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7930
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7681
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7983
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5514
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
1
2118
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1229
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
950
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.