Cascade Delete Query

Dec 7, 2006

Hello Friends,

I need some help to crete a query that will delete data in multiple tables.

My database has 5 tables. I store data in a main table and then append the ID and SSN to the other 4 tables.

The main table has also a purge date field that I will use to delete old records.

I use a form with a textbox where I type the starting date from which remove these records.

Is there a way or example I can see on how to remove all records at the same time. I have heard of cascade delete queries but really don't know how to use them.

My idea was to remove from the maintable all records with a date older than the date in txtbox and at the same time remove all records with the same ssn in all the other tables.

Thank you.

View Replies


ADVERTISEMENT

Queries :: How To Make Cascade Update / Delete

Jan 13, 2015

What I'm trying to do is making Cascade update and delete between two tables. For example in my case I have Field called Full name in table1 and I want the same field in table2 that will update when something is added in table1 and vice versa. I have tried relationship but I got an error that those fields does not have any unique value.

View 3 Replies View Related

Tables :: Cascade Delete Not Being Enforced Between Tables

Nov 19, 2014

I'm a newb to Access and SQL and database management. I have a main table and a dependent table with a 1 to 1 relationship, relationship integrity and cascade update and delete. I used an append query after I had modified several records, and after the append deleted one of the records from the main table. It remained in the dependent table. Access didn't catch the disparity even after a restart. I broke the link and tried to reestablish it, and of course Access wouldn't let me. I deleted the record manually from the dependent table and all was well.

Why would referential integrity/cascade delete not be recognized after an append query?Access 2010.

This is the second time in two days that cascade delete has been broken in two days after using a query on the main table. Yesterday, after referential integrity was broken, deleting the records from the dependent table allowed me to restore Cascade Delete functionality and it worked for the rest of the day.

View 9 Replies View Related

Query Lets Me Delete But Doesn't Actually Delete...

Apr 2, 2007

I have a query based on two tables, joined on one field (this field is the primary key in Table A. Table B doesn't have a primary key). When working inside this query, it gives me the option to delete records. However, when I try, the row disappears from the query but then if I save and close and either re-open table A or the resulting query, that record is back. It doesn't actually delete. If I go to table A directly and delete it, it's gone for good.

How can I make it so that when I delete the record inside the query it actually deletes? And if that's not an option, can I make it so that it doesn't seem like I can delete records inside the query so that people don't make the mistake?

View 2 Replies View Related

How To Delete Record Using Delete Query

May 19, 2011

I have two simple tables. I want to delete the records from Table1 that are on Table2. I've created a select query that gives me what I want but when I change to a delete query, I get this message: "Unable to delete from specified tables"

I think my problem has something to do with security but I can't figure out what to change.

View 13 Replies View Related

Cascade Deletes

Jun 13, 2007

I want to use Cascade Delete on a main table that has relationships with a few tables. The type of these relationships are weak and the delete will work perfectly I think. But, I am concerned about how I can only delete the FK from one of the tables because it contains a non-prime FK.

For example: Customer buys House. So Customer PK is in House as FK.
If I delete customer, I don't want house deleted. Is there anyway that is native to access in how I can only delete the FK from tblHouse without deleting the house record.

View 8 Replies View Related

Define Cascade From SQL

Oct 12, 2004

Hi, all... :)
I need to create cascade relationship on fly.
I've succeeded to create the relationship by:
ALTER TABLE tName ADD CONSTRAINT fk_id FOREIGN KEY(ID) REFERENCES tPrimary(ID)
and even succeeded to check the referential integrity by:
ALTER TABLE tName ADD CONSTRAINT fk_id FOREIGN KEY(ID) REFERENCES tPrimary(ID) CASCADE

The real problem comes when i am trying to enforce the cascades. I do not find any expression doing it.

the standarts of sql: on update cascade
or
of sql server: on update cascade go
just don't work in access :(

Thankful ahead

View 1 Replies View Related

Cascade-To-Null Foreign Key

Oct 19, 2007

Hello,

I'm using Allen Brownes very helpful cascade-to-null relations (http://allenbrowne.com/ser-64.html) code in my database project, but there comes problems whit a foreign key and null values, cause foreign key shouldn't be null. Is there anyone else using this method with relational tables? What I should do to make this work?

All hints and tips are welcome and approciated, thanks on advantage. =)

- IpeXeuS

View 14 Replies View Related

Cascade Combo - 3 Tiers?

Oct 14, 2005

Hello,

I followed the Microsoft guide detailing how to set up two cascading combo boxes. I would like to add a third box to the cascade. I have tried making some assumptions based on the code in the example but I can't get it to work.

I have three queries set up; qryBusiness, qryBusinessUnit and qryLocation.

I am using one form; frmToolInfo.

I have three combo set up; cboBusiness, cboBusinessUnit and cboLocation.


I amended my code to the following:


Private Sub cboBusiness_AfterUpdate ()
Me!cboBusinessUnit.Requery
Me!cboBusinessUnit.SetFocus
End Sub

Private Sub cboBusinessUnit_AfterUpdate ()
Me!cboLocation.Requery
Me!cboLocation.SetFocus
End Sub

Private Sub Form Current ()
Me!cboBusinessUnit.Requery
Me!cboLocation.Requery
End Sub



I want to cascade down from Business, to Business Unit to Location.


Can anyone advise me as to what I've done wrong here.

Thanks.

View 3 Replies View Related

Cascade Combo Boxes

May 25, 2005

How do I create Related Cascade Combo boxes by CD Group and Name of CD
To only display the records from NAme of CD related to the CD Group

Or to to a ABC and click on Artist and then click on the list with Name of CD


Someone else is wonderinf a friend of mine in Acess you can create a inventory Database to display records related like Name of Furniture Brand, Item and Search ny Last Name to see if they bought that Item

View 3 Replies View Related

Cascade Combo Problem

Oct 20, 2005

Hello,

I have a question on cascade combos.

I have a form named Welcome and would like to add two cascade combo boxes.

The first combo, named cbolist get's its data from a table named QUERIES which has three fields:

ID
QUERYNAME
QUERYDESCRIPTION

cbolist displays the records contained in the QUERYDESCRIPTION field which are basically the name of other tables of my database with different records (obviously).

I would like that after selecting a record in the cbolist, the second combo, which I will call cboresult, will populate with all the records of that specific table selected in the cbolist.

Any help with the correct code?
Thanks.

View 2 Replies View Related

Relating 2 Cascade Combo Boxes

Apr 30, 2005

I need help relating 2 Cascade combo boxes
I need the coding I see the example online at
http://www.fontstuff.com/access/acctut10.htm

But I need the Coding it explains good how it works
CD Group
CD Name

Displays CD Group related to the fields in CD Name

Thanks,

Mike Va nDer STad

View 3 Replies View Related

Cascade List Box Code Problem

Jun 6, 2005

I have 2 tables cD Group and Cd Name
2 forms CD Group and Name
I want to populate the fields in the cd Name form
When someone selects CD Group field
Mormon Tabernacle Chior

CD Name relates back only cd names to the cd group
God Bless America

Here is the coding
Row Source CD Group
SELECT DISTINCT [CD Group with Name].[CD Group] FROM [CD Group with Name] ORDER BY [CD Group with Name].[CD Group];


Event Procedure After Update
CD Names
SELECT [CD Group with Name].[CD Name] FROM [CD Group with Name] WHERE ((([CD Group with Name].[CD Group])=Forms!frmCDs!cboGroup.value));

SQL Query

Field CD NAme
Table CD Group with Name
Field CD Group
Table CD Group with Name
[Forms]![frmCDs]![cboGroup].[value]

Private Sub Command8_Click()
On Error GoTo Err_Command8_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Track Table Test"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command8_Click:
Exit Sub

Err_Command8_Click:
MsgBox Err.Description
Resume Exit_Command8_Click

End Sub

Private Sub fldCDGroups_AfterUpdate()

End Sub

Private Sub fldCDName_AfterUpdate()

End Sub

Thanks,
for any help

mikevds@optonline.net

View 1 Replies View Related

Forms :: Cascade Combos With Union

Sep 19, 2014

I'm trying to filter a combo based on the selection in another combo.The twist is that I need the row source of both combos to include an "*", "(All)" selection, as I am using these combos to filter a listbox. When I add the Union query with "*", "(All)", the row source in the 2nd combo is ignoring the where clause.

After making a selection in the Comp combo, the Emp combo should be filtered. It works with no Union in the row source, but does not work with the Union in the row source.

View 2 Replies View Related

Cyclic Cascade Update? DB Design Question

Jul 12, 2007

Is this scenario considered bad design form? (see attached image)

I'll never delete a Customer or Site for whom a a Job exists. I need historical data to remain intact. I'll just mark a Customer or Site as [InActive] so they can't be used, when appropriate.

If the relationships are considered good form, then what is considered good form when deciding upon which relationships to set to Cascade Update? Do I even need to update autonumber foreign keys?

On upsizing this database, SQL complains that this arrangement is a cyclic update and won't create the relationship unless I tell it to use Triggers. This leads me to question whether I'm correctly using Cascade Updates in my Access db's.

Thank you.

View 4 Replies View Related

Cascade Combo Box Previous CD Group List Box

Apr 29, 2005

I need directions on Cascade Combo Box, So when I select:

CD Group

Displays only the CD's in that Group that are related to that Name
So what fields would I have to set up for CD Group and CD NAme with that Table.
Someone emailed me an article on Cascade combo boxes what fields so I need for the coding.......

View 2 Replies View Related

Tables :: Simple Cascade Update Not Working

Oct 29, 2013

I've done this tons of times, so I don't understand what's happening... The title says it all: when I update the ID of one record of the main table, the referenced records on related tables won't update even though they have a relationship between them with the option "Cascade update" clicked.

In the attached database, the main table "Expedientes" is related to table "Actuaciones".

View 1 Replies View Related

Forms :: Making Cascade Combobox With 4 Comboboxes?

Dec 2, 2013

I want to make a form where i have 4 comboboxes in a cscade combobox thing.

I already made 4 tables with info.

- My first table contains devices:

- ApparaatID (Primairy key)
- Apparaat(with 4 entries)

- My second table contains if it is hardware or software:

- TypeID (Primairy key)
- ApparaatID
- Type (where I entered hardware and software in 2 different entries)

- The thirt table contains operating systems:

- OSID (Primairy key)
- ApparaatID
- TypeID
- OS_versie (where I entered all the OS I want to enter)

Now I made a form I called problemen with 4 comboboxes.

- cboApparaat
- cboType
- cboOS
- cboProbleem

1) What I want is that when you select device 1 and 4 that cboType can select both hardware and software but with device 2 and 3 you can only select software.

2) If you have selected software is cboType I want you to be able to select 1 of the 11 OS I have pre-entered in the table.

3) That you get specific problems with the previous made choices. For example if you select Hardware in cboType, thta you only get problems with hardware to select from and the same with software and OS.

4) I want a textbox, that will contain the solution of the problem you selected and that if there and several solutions that you get all of them at once.

View 13 Replies View Related

Referential Integrity: Cascade Update Not Working As Expected???

Nov 2, 2006

Hi,
I have a database with a couple of tables. The primary table has a primary key called "StaffNo". I checked the relationships between the primary table and each related table, if I have ticked on the boxes for referential integrity, cascade updates. All done. If I now create a query, which selects the primary table and one related table and enter a new StaffNo, I would expect to see the new StaffNo not only in the primary table but also in the related one. But there is nothing. Do I expect wrong? Have I missed sth.? I read a few posts in this and other forums reg. referential integrity, but I have no clue, what's wrong. :confused:
Any quick help is much appreciated.
Thanks :)

View 1 Replies View Related

General :: Cascade Combo Boxes With Duplicate Values

Jan 18, 2013

I'm trying to Identify a particular entry in my table for editing via combo boxes. The same serial number will come in multiple times but a different job number each time it comes in. To identify a record for editing I need the user to identify the serial number in combo1 and then the job # in combo2 (cascaded combo boxes).

The issue I'm running into is that combo1 has dozens of serial number duplicates (combo2 is acting as it should). When I change some settings around I'm able to get combo1 to eliminate duplicates but now combo2 only shows 1 job # when there should be dozens for that serial #. I need all like serial numbers to show their job # in combo2 and I have not had any luck surfing around the net/forums/experimenting.

I'm pretty sure I have to use a Junction Table but I haven't messed with that and I'm not 100% sure that's the best/only way to do it.

View 8 Replies View Related

Tables :: Invalid Field Definition - Not Able To Set Up Cascade Update

Jun 9, 2014

(named: Invalid Field Definition - Unable to set up cascade update but I have done what the moderator advised and have not been able to fix a very similar problem.

I have planned a database and must adhere to the plan or change it and basically I initially said that I would like to enforce referential integrity to synchronise my tables and I would also like to cascade update and delete to save input time because changes will be automated between table (where fields are connected.).

I have attached a plan I did if that makes the purpose of my database clearer.I have attached my database and have established the relationships* without referential integrity enforced I would like between my tables but don't know how to make them one-to-many relationships nor can I enable cascade update or cascade delete or enforce referential integrity.

I am new to databases (and to this forum) and have been promised by my line manager that I won't have to specialise, I don't think I have created the relationships but they are supposed to be between Vehicle ID and Hire Number, and Customer ID and Hire Number.

View 1 Replies View Related

Forms :: Auto Fill In A Text Box If Value Selected From Last Of 4 Cascade Comboboxes

Dec 9, 2013

I use access 2013.

1) How to auto fill in a text box if you select a value from the last of 4 cascade comboboxes.

I have 4 comboboxes where

1 = Apparaat - cboApparaat
2 = Type - cboType
3 = OS - cboOS
4 = Probleem - cboProbleem

With all 4 comboboxes I have the vba code Me.cbo[name combobox].Requery

If I select the last combobox, cboProbeem. I want the textbox underneath to automaticly fill in the solution of that problem. I already tried to use the following vba code

Me.Oplossing = Me.cboProbleem.Column(5)

But it does not work.

2) I want to make a form for customers, where I can fill in customer info, device info and date when there contract started. Now I want to use SUM to fill in the end date of there contract.

View 3 Replies View Related

Queries :: Export Query To Excel Then Delete Query Data From Table

Nov 20, 2013

I am wondering if there is a quicker way to export a query to excel then have the data in that query removed from the original table. (effectively cutting the data from the table and exporting to excel)

I understand that this can be done by exporting the query to excel then running the same query as a delete query to remove the data but I just wondered if this is the most efficient way.

I have experience of VB in excel but currently only use the basic macro builder in Access though if Access VB is more efficient I can easily learn.

View 5 Replies View Related

Access 2010 - Delete Form Command Button With A Password To Confirm Delete

May 6, 2014

All I am trying to do is insert to have a form with a "Delete Record" button on it. The problem is I don't want anyone to be able to delete a record, I would like someone to have to insert a password to confirm the delete.

View 13 Replies View Related

Delete Query

Apr 4, 2006

Can anyone help?

i have set up the delete query:

DELETE dbo_MP_Audit.*, dbo_CAD_SINV_HEADER.SIN_CANCELLED_YNF
FROM dbo_MP_Audit INNER JOIN dbo_CAD_SINV_HEADER ON (dbo_MP_Audit.Usr = dbo_CAD_SINV_HEADER.USR_CODE) AND (dbo_MP_Audit.Sin_DocNum = dbo_CAD_SINV_HEADER.SIN_NUMBER) AND (dbo_MP_Audit.company = dbo_CAD_SINV_HEADER.CMP_CODE)
WHERE (((dbo_CAD_SINV_HEADER.SIN_CANCELLED_YNF)=1));

but receiving error message: "could not delete from specified tables".

View 3 Replies View Related

Delete Query

Aug 24, 2007

I have a table that has records listed more than one time. Some of these multiple records have in the score field a zero for the score. I would like to remove all records that are in the table more than once that have a zero for the score in the score field. Any help is greatly appreciated!

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved