Solved

access deleting related records

Posted on 2013-01-23
6
383 Views
Last Modified: 2013-01-24
Suppose i have a client table and a related file table.

one client many files.

They have referential integrety

If I want to delete one client record and it related files is there an easy and safe way to do this.
Do delete the referential integrity in Relationships and then delete the two files manually. Or is it cascade upwards or something?

Or is there a way to delete all related records that belong to the client with a query say, without having to change the Relationships between the tables.
Sorry this is bit half baked but its late and I should be in bed.
0
Comment
Question by:topUKlawyer
  • 3
  • 2
6 Comments
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Access MVP) earned 350 total points
ID: 38812340
IF ... you have Enable Cascade Deletes checked in the Relationships dialog, then this should happen automatically.
And I've never had an issue with this.

mx
0
 
LVL 13

Assisted Solution

by:AielloJ
AielloJ earned 150 total points
ID: 38812357
topUKlawyer:

There are two options when you create a relationship that controls what you want to do.  The first, called 'Cascade Update Related Fields' will automatically update the foreign keys in related ttables whenever the primary ID in the parent tables is changed.

The second option called, 'Cascade Delete Related Records' will delete any child records whenever the parent row is deleted.

I would refrain from changing table relationships from within your applicaiton.  There are a number of risks that practice could cause that will have you spending hours getting things to work again.

Regards,

AielloJ
0
 
LVL 75
ID: 38812384
Just to be check ... refer to image below:

mx

Cascade Delete Related Records
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Author Comment

by:topUKlawyer
ID: 38815165
Is there a way you can have Cascade delete checked and then put some other measure on the other users (other than me) which will restrict or make it hard for them to delete records.
I know I can make the tables invisible to them (I think)
0
 
LVL 75
ID: 38815395
Well, at the Form level, you can Not Allow Deletes ...

I guess I am not understanding the goal here RE:

"If I want to delete one client record and it related files is there an easy and safe way to do this."

If you enable Cascade Deletes, then the answer is Yes.  And I see no reason to not do this.

mx
0
 

Author Closing Comment

by:topUKlawyer
ID: 38815446
thanks Experts
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

This article will show you how to use shortcut menus in the Access run-time environment.
Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now