Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleted Content - Output To...

Status
Not open for further replies.

lissa5402

Technical User
Nov 6, 2009
6
US
Is there a way to create a query that would run each time a table entry is deleted and output the data that was deleted to another table or query?

We have several tables set up in Access and I would like to find a way to capture all those records that are deleted so that my relationship with the table won't be broken once something is deleted. (Entire rows are deleted at any time.)
 

If you want to create an archive table, simply copy the current one. Whenever a row is deleted, run an append query FIRST.
Another way, which I prefer, is to add another field to the table -- call it status. Include it in the WHERE clause of all queries.

Randy
 
so that my relationship with the table won't be broken
Why not use the referential integrity ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
<i> "add another field to the table -- call it status. Include it in the WHERE clause of all queries." </>

I don't know exactly what that means or how to do it.

<i> "Why not use the referential integrity ?"</i>

I don't know how to do that or what that means either.
 
"add another field to the table -- call it status. Include it in the WHERE clause of all queries."

I don't know exactly what that means or how to do it.

"Why not use the referential integrity ?"

I don't know how to do that or what that means either.
 
I don't know how to do that or what that means either
Do a google search for referential integrity msaccess

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
option #1:
add a field to the table
name the field status
run an update query and set the status of all the current records to 'Active'
Code:
Update TableName Set Status = 'Active'
When someone wants to delete a record instead of deleting it change the status field to 'Deleted'

Modify all the queries to have a WHERE clause of:
Code:
WHERE Status = 'Active'

option #2
in the Relationship window of Access
set up a relationship between your main table's primary key and a dependant table's foreign key.
Change the property of the relationship to 'Enforce Referential Integrity' so that when a record is deleted from your main table it is also deleted from the dependent tables based on your key.

HTH

Leslie
 
Is there a way to create a query that would run each time a table entry is deleted and output the data that was deleted to another table or query?

Yes. If your data is being deleted programmatically or via forms.

No. If your users are deleting data directly from a table or query.

Greg
People demand freedom of speech as a compensation for the freedom of thought which they seldom use. Kierkegaard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top