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 Replies


ADVERTISEMENT

Problem With Deletes.

Apr 12, 2005

Hello,!

I have a stand-alone form with one table as its source with no referential integrity issues. I am using Access 2000 version.

I used the commands
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

to delete a record, and it does nothing, no error message, but does not delete either.

I found the help site

http://support.microsoft.com/default.aspx?scid=kb;en-us;182435

They mentioned it sa for Access 97, but I thought it relates to what I was facing. I took off the Modal and Pop-up properties back to 'No'. Still the same problem. Then I substituted the above 2 commands with
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdDeleteRecord

But now I get the error message

The command or action 'DeleteRecord' isn't available now..

Have you seen this before? Any help is greatly appreciated.

Vchell.

View 3 Replies View Related

Weird Bug: OutputTo Deletes (!) Query

Dec 1, 2007

Hi guys & gals,

I recently came across this really strange behaviour and was wondering if anyone else knows this bug or knows a better workaround than mine.

I've attached a little Events DB, which has a search interface. I've included an export button, which runs a macro that does an OutputTo (xls) of the search query.

Now if you do an export once, everthing is fine. The bug (at least I think it's a bug) occurs if you export a *second* time and *overwrite* the file you created earlier. The search query (which sits under the "Queries") tab is now empty and you get an error message.

My workaround idea was to dump the query to a new table every time you export and then do an OutputTo with this table. Not very elegant and you also have to do the whole error handling (e.g. user presses cancel) manually.

Does anyone have a better idea? Or am I doing somethng completely wrong and this is actually "by design"?!

Thanks in advance for any ideas!

View 2 Replies View Related

Parent-Child Cascading Deletes

Nov 4, 2007

I have a simple Family table:

PersonID
Name
ParentID

where, in the case of a child, its ParentID contains the PersonID of its parent.
In the Relataionships window I put two such tables, Family and Family_1 and I joined Family.ParentID to Family_1.PersonID. I set referential integrity, cascading updates and cascade deletes.
I made a Parents form (by setting the ParentID criteria to Is Null), and added a Children subform (linking the ParentID of the subform to the PersonID of the main form).

The cascading updates works when I add a new child but when I try to delete a parent I get the error: Could not update; currently locked.
Why doesn't the cascade delete work?

View 3 Replies View Related

Button Deletes All Related Records - Help!

Feb 20, 2005

I have a problem where a button is deleting all the records related to one record, I was hoping somebody could help. Here's the problem:

OrderID is an attribute in table tblOrders. It is related (with Cascade update related records) to OrderID in tblTurkeys. In a form with a button which deletes a particular OrderID from tblOrders, when this button is clicked, if there are records in tblTurkeys with that OrderID, the record in tblOrders cannot be deleted. And if I changed the relationship type to cascade delete, the record in tblTurkeys will be deleted. Basically, I want the button to, before deleting the record in tblOrders, make the value of the OrderID attribute of any records in tblTurkey with the same OrderID as the one being deleted to have no value.

Eg. Record in tblOrders is being deleted. It's OrderID is 2. There are two records in tblTurkeys which have OrderID attributes of value 2, so when the record in tblOrders is being deleted, the values of the OrderID attributes previously mentioned as being in tblTurkeys now have no value.

That's what I need it to do! If anyone can help, I'd be greatly thankful!

View 5 Replies View Related

Delete Record Deletes Other Records

May 11, 2006

I have something very bizarre happening that I cannot figure out.

I have a form with a subform on it. These are not linked. On the first form is one combo box, the records in the subform are requeried every time the combo box changes with the criteria for the subform based on the selection in the combo box.

I haven't got these linked because I also have an Edit option group selection on the main form which changes the subform from Data Entry = False and AllowAdditions = False to Data Entry = True and AllowAdditions = True. This allows me to use the form to enter new records or to edit existing ones by changing the edit mode.

I also have a delete button on this form with the generic code to delete a record:

DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

The record source for this subform is a primary table on the one side of a one to many relationship.

When I am in the new record mode (Data Entry = True and AllowAdditions = True) and I delete the record I am currently entering it works as expected.

When I am in edit mode (Data Entry = False and AllowAdditions = False ) and I delete the record I am on. It deletes the record but any record in the many side (the secondary table with the foreign key) is also deleted as well. Now I'd expect it to delete the foreign key on the many side and wipe the field but this actually deletes the whole record the foreign key is in from the secondary table.

I have checked my relationship set up for these tables and they are fine:

One To Many Relationship
Referential Inegrity Checked
Cascade Update Records Checked
Cascade Delete Records Checked

I get the usual access warning telling me it is about to delete one record. usually you would also expect the warning to include the comment about this deletion will also delete any related records in other tables, but I don't get that.

I cannot for the life of me figure out why the whole record from the secondary table is being deleted and not just the related field.

Does anyone have any ideas?

I hope I have explained it properly. (Tis always hard to put into words a problem)

Thanks in advance,

Daz

View 2 Replies View Related

Compact And Repair Deletes Data...

May 26, 2005

Access 2k with all updates and SPs:

When compacting a particular db deletes 1000s or records from one particular
table. I can't see a problem with the data in that table, but I also get
error messgaes if I try to append the data from that table into another
table or to import it into another db.

We've had to go back to a restored copy and have lost 1 days worth of data.
Not the end of the world, but I have no idea what is causing this.

Has anyone seen this before?

TIA,

Mo

View 2 Replies View Related

Tables :: Append That Deletes Previous Contents Of Table

Sep 14, 2012

I have Access 2010 tables linked to Sharepoint 2010 lists and my table becomes disconnected when I run a delete query on the table in Access.

I can append the table and Sharepoint stays connected.

Can I do an append that deletes the previous contents of the table?

View 1 Replies View Related

Forms :: Refreshing Textbox If User Deletes A Record From Table

Feb 6, 2015

I have a form with a Count textbox. It's control source is a field named "Audit Count" in the table "DB Audits". The idea of the textbox is to display a running count of how many audits a specific auditor has completed that day. To do this I have the textbox set up with a default value of:

Code:
=DCount("[Loan Number]","DB Audits","[Auditor] = fOSUserName() And [Audit Date] = Date()")+1

Assuming I'm using the DCount function correctly, this is supposed to count the number of [Loan Number] records entered in the "DB Audits" table by the auditor (whose name is found using fOSUserName()) on today's date. So, for example, when opening up the form at the beginning of the day the Count textbox would read 1 and when the auditor clicked Save and New it would increase to 2.

The problem I am having is something I encountered while doing some random tests of the form. If an auditor submitted an audit (let's say the 1st of the day), the form correctly displays the next count as 2. However, if the auditor were to delete the record from the underlying "DB Audits" table while the form was still open, if they were to enter a new record, the Audit Count field would display 2 even though it should be 1 (since the 1st record had been deleted).

How can I have the Count textbox refresh whenever someone deletes a record from the table while the form is still open? I tried a Requery command using the AfterDelConfirm event but I couldn't get it to work.

View 6 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

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 3 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

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

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







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