473,387 Members | 1,561 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,387 software developers and data experts.

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.SupplierCode, Items.UpdatedDateTime, [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.ItemNumber
WHERE (((Items.SupplierCode)=[Forms]![frmImport]![cmbSuppliers]) AND
((Items.UpdatedDateTime)<>[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.SupplierCode, Items.UpdatedDateTime
FROM Suppliers INNER JOIN Items ON Suppliers.SupplierCode =
Items.SupplierCode WHERE
(((Items.SupplierCode)=[Forms]![frmImport]![cmbSuppliers]) AND
((Items.UpdatedDateTime)<>[Forms]![frmImport]![DTNOW1]));"

Many thanks
Rob
Apr 11 '06 #1
2 2001
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.SupplierCode, Items.UpdatedDateTime, [Check if


Try DELETE DISTINCTROW Items.* FROM ....

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

"kaniest" <ka*****@invalid.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.SupplierCode, Items.UpdatedDateTime, [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
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...
10
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...
14
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...
8
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...
2
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...
16
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...
13
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...
5
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...
10
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. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
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...

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.