473,399 Members | 2,146 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,399 software developers and data experts.

Difficulty trying to delete records

I have two tables: Deliveries and Invoices. An Invoice can relate to a
number of Deliveries.

The relevant fields are:
Invoices:
InvoiceID
InvoiceDate

Deliveries:
DeliveryID
DeliveryDate
InvoiceID

Sometimes deliveries are cancelled and so the associated invoice may
need to be deleted. I tried to run the following query:

Delete * From Invoices Left Join Deliveries On Invoices.InvoiceID =
Deliveries.InvoiceID Where Deliveries.InvoiceID Is Null

i.e. attempting to remove all Invoice records which do not have any
associated Delivery records.

However I get the error message:
"Could not delete from specified tables"

What is going wrong?
How can a I achieve this?

Ron

PS if I make the query into a Select query, it displays just the
records I wish to delete!

Nov 26 '06 #1
2 1437
"Jim Devenish" <in***************@foobox.comwrote in
news:11**********************@j44g2000cwa.googlegr oups.com:
I have two tables: Deliveries and Invoices. An Invoice can
relate to a number of Deliveries.

The relevant fields are:
Invoices:
InvoiceID
InvoiceDate

Deliveries:
DeliveryID
DeliveryDate
InvoiceID

Sometimes deliveries are cancelled and so the associated
invoice may need to be deleted. I tried to run the following
query:

Delete * From Invoices Left Join Deliveries On
Invoices.InvoiceID = Deliveries.InvoiceID Where
Deliveries.InvoiceID Is Null

i.e. attempting to remove all Invoice records which do not
have any associated Delivery records.

However I get the error message:
"Could not delete from specified tables"

What is going wrong?
How can a I achieve this?

Ron

PS if I make the query into a Select query, it displays just
the records I wish to delete!
Access often refuses to run deletes on left-joined tables.
Try this alternative method of filtering, it usually works

Delete * From Invoices
WHERE InvoiceID NOT IN
(SELECT invoiceID from Deliveries)
--
Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com

Nov 26 '06 #2
Thanks Bob. It worked a treat

Jim
Bob Quintal wrote:
"Jim Devenish" <in***************@foobox.comwrote in
news:11**********************@j44g2000cwa.googlegr oups.com:
I have two tables: Deliveries and Invoices. An Invoice can
relate to a number of Deliveries.

The relevant fields are:
Invoices:
InvoiceID
InvoiceDate

Deliveries:
DeliveryID
DeliveryDate
InvoiceID

Sometimes deliveries are cancelled and so the associated
invoice may need to be deleted. I tried to run the following
query:

Delete * From Invoices Left Join Deliveries On
Invoices.InvoiceID = Deliveries.InvoiceID Where
Deliveries.InvoiceID Is Null

i.e. attempting to remove all Invoice records which do not
have any associated Delivery records.

However I get the error message:
"Could not delete from specified tables"

What is going wrong?
How can a I achieve this?

Ron

PS if I make the query into a Select query, it displays just
the records I wish to delete!
Access often refuses to run deletes on left-joined tables.
Try this alternative method of filtering, it usually works

Delete * From Invoices
WHERE InvoiceID NOT IN
(SELECT invoiceID from Deliveries)
--
Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com
Nov 26 '06 #3

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

Similar topics

1
by: longtim | last post by:
I have been having endless difficulty creating reports/queries that set any relevent parameters from controls in forms. I am creating an application under access 2003 but will target access...
3
by: Jeff | last post by:
In a subform I have a simple SQL statement that links an order details table to a product table. The form is used to enter order details. Most fields are obviously from the details table, with only...
4
by: NancyJ | last post by:
Currently we have a database with a main table containing 3 million records - we want to increase that to 10 million but thats not a possibility at the moment. Nearly all 3 million records are...
19
by: dba_222 | last post by:
Dear Experts, I've worked with Oracle since 1995. I have gone very deep into many of the Oracle features, including sqlloader, and export/import. And I've done data modelling even longer. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
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.