473,549 Members | 2,784 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help! cannot delete records in the table "PRODUCTS"

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 the table, but I was not allowed to do that, because
"there are records related with those PRODUCTS in other tables (e.g. in
table "ORDER_DETAIL") .

Who knows how to solve this problem?

Any ideas, advise are very much appreciated. Thanks.

Paul T. RONG
Nov 13 '05 #1
6 3081
Paul T. Rong wrote:
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 the table, but I was not allowed to do
that, because "there are records related with those PRODUCTS in other
tables (e.g. in table "ORDER_DETAIL") .

Who knows how to solve this problem?

Any ideas, advise are very much appreciated. Thanks.

Paul T. RONG


Delete the related records in ORDER_DETAIL then you'll be able to delete the
records from PRODUCTS. Else ensure that cascade deletes are turned on
within referential integrity.
Nov 13 '05 #2
Hi
First delete the related records and then the products. Or delete the
relationship but you will have orphaned records, not a good idea
Alfred

"Paul T. Rong" <et***@hotmail. com> wrote in message
news:uJ******** **********@news .chello.at...
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 the table, but I was not allowed to do that, because
"there are records related with those PRODUCTS in other tables (e.g. in
table "ORDER_DETAIL") .

Who knows how to solve this problem?

Any ideas, advise are very much appreciated. Thanks.

Paul T. RONG

Nov 13 '05 #3
But, the related records are more than two thousand, it will be very hard to
delete all of them.

And for some reason, I would like to keep all old records, is it
THEORETICALLY
possible, I mean, to delete the unwanted records in PRODUCTS table but at
the same time to leave the old related records in other tables unchanged?

Last, who can help to explain more simply on "cascade deletes", I don't
think I
understand that term. Many thanks in advance.

Paul


"Deano" <de*********@ho tmail.com> дÈëÏûÏ¢ÐÂÎÅ
:b2************ *********@stone s.force9.net...
Paul T. Rong wrote:
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 the table, but I was not allowed to do
that, because "there are records related with those PRODUCTS in other
tables (e.g. in table "ORDER_DETAIL") .

Who knows how to solve this problem?

Any ideas, advise are very much appreciated. Thanks.

Paul T. RONG
Delete the related records in ORDER_DETAIL then you'll be able to delete

the records from PRODUCTS. Else ensure that cascade deletes are turned on
within referential integrity.



Nov 13 '05 #4
If you want to retain the related records, then don't delete the "parent"
Products records. Instead, add a column to the Products table, and call it
"Active". Make it a Yes/no field. Instead of deleting a Product, just set
the value of Active to "no".

Then fix up your forms, reports, and queries to just show records from the
Products table where Active = "yes".

Anne Nolan

"Paul T. Rong" <et***@hotmail. com> wrote in message
news:nq******** **********@news .chello.at...
But, the related records are more than two thousand, it will be very hard to delete all of them.

And for some reason, I would like to keep all old records, is it
THEORETICALLY
possible, I mean, to delete the unwanted records in PRODUCTS table but at
the same time to leave the old related records in other tables unchanged?

Last, who can help to explain more simply on "cascade deletes", I don't
think I
understand that term. Many thanks in advance.

Paul


"Deano" <de*********@ho tmail.com> дÈëÏûÏ¢ÐÂÎÅ
:b2************ *********@stone s.force9.net...
Paul T. Rong wrote:
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 the table, but I was not allowed to do
that, because "there are records related with those PRODUCTS in other
tables (e.g. in table "ORDER_DETAIL") .

Who knows how to solve this problem?

Any ideas, advise are very much appreciated. Thanks.

Paul T. RONG


Delete the related records in ORDER_DETAIL then you'll be able to delete

the
records from PRODUCTS. Else ensure that cascade deletes are turned on
within referential integrity.


Nov 13 '05 #5
Paul T. Rong wrote:
But, the related records are more than two thousand, it will be very
hard to delete all of them.

And for some reason, I would like to keep all old records, is it
THEORETICALLY
possible, I mean, to delete the unwanted records in PRODUCTS table
but at the same time to leave the old related records in other tables
unchanged?
Thing is, if you have established a relationship between the two then you
are always going to have this problem. Should there be a one-2-many
relationship between them in the first place?
Last, who can help to explain more simply on "cascade deletes", I
don't think I
understand that term. Many thanks in advance.


From Access 2000 help;

"If you select the Cascade Delete Related Records check box when defining a
relationship, any time you delete records in the primary table, Microsoft
Access automatically deletes related records in the related table. For
example, If you delete a customer record from the Customers table, all the
customer's orders are automatically deleted from the Orders table (this
includes records in the Order Details table related to the Orders records).
When you delete records from a form or datasheet with the Cascade Delete
Related Records check box selected, Microsoft Access warns you that related
records may also be deleted. However, when you delete records using a delete
query, Microsoft Access automatically deletes the records in related tables
without displaying a warning."

To change this go into Tools, Relationships and double-click on the line
connecting your tables.
I reckon Enforce Referential Integrity is checked.
If you uncheck that then you can do what you want but it's going to leave
your tables in a messy state - there will be references in one table to
records that no longer exist.

I think you can sidestep this by following Anne's advice.


Nov 13 '05 #6

Anne, great ideas! thanks you!!!

"Anne Nolan" <an************ ***@AOL.COM> дÈëÏûÏ¢ÐÂÎÅ
:2i************ @uni-berlin.de...
If you want to retain the related records, then don't delete the "parent"
Products records. Instead, add a column to the Products table, and call it "Active". Make it a Yes/no field. Instead of deleting a Product, just set the value of Active to "no".

Then fix up your forms, reports, and queries to just show records from the
Products table where Active = "yes".

Anne Nolan

"Paul T. Rong" <et***@hotmail. com> wrote in message
news:nq******** **********@news .chello.at...
But, the related records are more than two thousand, it will be very hard
to
delete all of them.

And for some reason, I would like to keep all old records, is it
THEORETICALLY
possible, I mean, to delete the unwanted records in PRODUCTS table but

at the same time to leave the old related records in other tables unchanged?
Last, who can help to explain more simply on "cascade deletes", I don't
think I
understand that term. Many thanks in advance.

Paul


"Deano" <de*********@ho tmail.com> дÈëÏûÏ¢ÐÂÎÅ
:b2************ *********@stone s.force9.net...
Paul T. Rong wrote:
> 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 the table, but I was not allowed to do
> that, because "there are records related with those PRODUCTS in other > tables (e.g. in table "ORDER_DETAIL") .
>
> Who knows how to solve this problem?
>
> Any ideas, advise are very much appreciated. Thanks.
>
> Paul T. RONG

Delete the related records in ORDER_DETAIL then you'll be able to
delete the
records from PRODUCTS. Else ensure that cascade deletes are turned on
within referential integrity.



Nov 13 '05 #7

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

Similar topics

5
5074
by: Jucius | last post by:
Using Delphi for developing, I get and delete records from an Access Database 2000. Sometimes, It happened 3 times (but not reproductible), the application did not succeed in connecting the database. A table is corrupted and when you compact, this table is deleted with an error -1206 created. I did not find resources on this problem on...
2
1778
by: MLH | last post by:
I have a table with the following fields: AreaID AreaCode Exchange City The table is in an Access 97 database. The table actually resides on a Linux box and is attached via a MySQL ODBC process. I want to write a pass-through query to delete records with AreaCodes beginning with 5. I am not familiar with Pass-Through and could use a...
7
1489
by: Paul T. Rong | last post by:
Hi everybody, I can not add into the "order_detail" subform a product more than once. The subform just refuses accepting any repeated items. The subform's source is a "expanded_order_detail" query which is based on "order_detail" table and the "product" table. The "order_detail" table has two primary keys: "OrderID" and "ProductID". A...
2
2008
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 ? Query as follows: DELETE Items.*, Items.SupplierCode, Items.UpdatedDateTime, .ItemNumber FROM RIGHT JOIN Items ON .ItemNumber = Items.ItemNumber...
18
2566
by: shinyo21 | last post by:
Anyone know how to create a SQL or way in Access for deleting few tables' record. I means is delete all the records in specify few tables. I tried to use query to delete the records' table but only one table by one query only. Anyone know the better way? shinyo
6
11256
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 the rows in the table using the traditional DELETE FROM EMPLOYEE stmt. It is taking around 53 secs to delete all the records. So I have done the...
4
8660
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 adodcAllEntries.Recordset.Delete End If
6
4078
by: scott.tang | last post by:
I'm experiencing a very strange problem. My application is MS Access front-end and MS SQL server back-end database. I have a SQL statement that deletes records from a table after an export process. The problem is occasionally when the delete statement is executed, these records no longer display on List Box (not even in the MS Access link...
6
4031
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 records that somebody started and closed out of, but then I realized that it wont delete the main records that information is recorded in if the sub...
0
7518
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
7715
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. ...
0
7808
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...
0
6040
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5368
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...
0
5087
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3498
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1935
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
0
757
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.