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 Replies


ADVERTISEMENT

Modules & VBA :: Delete Of A Record From A List Of Records In A Subform Deletes Wrong Record

Jun 28, 2013

When we browse through records in a subform we store the records in the database.When we want to delete a records for example the third record from the five records always the first records will be deleted. How can we delete the records where the cursor is at? When we are at the third record and press the delete button the third record from the list in the subform should be deleted.

Code:

Option Compare Database
Dim FocusBln As Boolean
Private Sub Identificeer()
Me.[Datum Aangemaakt].Visible = True
Me.[Datum Aangemaakt].SetFocus
If Me.[Datum Aangemaakt].Text = "" Then

[code]...

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

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

Delete Record Only If Child Records Don't Exist

Aug 6, 2005

Hi,

I'm trying to have a button on a form that would delete a record from a table only if there are no child records linked to it.

If there are child records for the selected record, the button would be disabled.

Is there a simple way of doing this?

TIA.

View 3 Replies View Related

Delete Records From One Table Based On Record From Another

Oct 10, 2014

I want to Delete all records from the Table Named "CustomerWiseRotaryTillerRates" (Given Below) if the State in the State Filed in found in the "Customer_Master" Table (attached Herewith). What will be the correct procedure ?

I followed the steps referred in page no. 67 & 68 in the Book "Microsoft Access 2007 Data Analysis" by Mr. Michel Alexender.

Customer Name
State
Product_Code
Product_Name
Price_perunit

TSI Engineering Indutries (P) Ltd.
Assam
P_05
1500_Rotary_Tiller_220_RPM
Rs. 63,722.00

Kishan Krishi Engineering Works
Jharkhand
P_05
1500_Rotary_Tiller_220_RPM
Rs. 62,997.00

TSI Engineering Indutries (P) Ltd.
Assam
P_06
1750_Rotary_Tiller_220_RPM
Rs. 66,663.00

Shri_Tata_Enterprises
Bihar
P_06
1750_Rotary_Tiller_220_RPM
Rs. 65,683.00

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

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

Modules & VBA :: Delete Records From A Table Based On Records In Another

Feb 7, 2014

I have a table InvPrice and Updated Pricing

Need to delete all records from InvPrice that Match UpdatedPricing

InvPrice.StockCode = UpdatedPricing.StockCode
InvPrice.PriceCode = UpdatedPricing.StockCode

I have tried something like this...

Dim dbs As DAO.Database, sql As String, rCount As Integer
Set dbs = CurrentDb
sql = "DELETE * dbo_InvPrice Inner Join (dbo_InvPrice Inner Join UpdatedPricing on dbo_InvPrice.StockCode = UpdatedPricing.StockCode ) ON on dbo_INvPrice.PriceCode = UpdatedPricing.PriceCode "
dbs.Execute sql, dbFailOnError

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

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

Delete Duplicate Records Or Blank Records

Mar 19, 2007

I want to find duplicate records based on FirstName and LastName and delete the duplicate. Also, I want to delete any records which have a blank FirstName and LastName.

How can I do this?

Thanks,

Dave

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

Cannot Delete Records

Jan 8, 2007

I have a query of records that are not related to records is the secondary table. I want to delete these records but when I select the records and click delete I get the confirmation to delete answer to delete them and all the records disappear. When I run the query again, all the records are still there. Does anyone know what is happening? This is an access front end that connects to a SQL server database.

View 1 Replies View Related

Delete Records

Apr 6, 2007

This works perfectly.

SELECT DOCSADM_PROFILE.SYSTEM_ID, DOCSADM_PROFILE.AUTHOR, DOCSADM_SECURITY.THING, DOCSADM_SECURITY.PERSONORGROUP, DOCSADM_SECURITY.ACCESSRIGHTS
FROM DOCSADM_PROFILE INNER JOIN DOCSADM_SECURITY ON DOCSADM_PROFILE.SYSTEM_ID = DOCSADM_SECURITY.THING
WHERE (((DOCSADM_PROFILE.AUTHOR)=21941909) AND ((DOCSADM_SECURITY.PERSONORGROUP)=4038));

Now how do i tell this query to delete these selected records from security table....?

View 6 Replies View Related

Delete Records

Mar 17, 2005

I have a survey form that has the questions on a subform based on the response to one of the survey demographic questions (via a query based on that response). The answers to the questions are on a sub-sub form. How can I get the program to delete the answers that were entered (they are related to the primary survey form with a common ID number) if the user changes the survey response.

In other words, if the user of SurveyID 5 decides that they want to fill out the list of blue questions rather than red questions, how can I delete all the answer blue records for SurveyID 5? Right now, it will display the red questions if you change to red and enter red answers, but the blue answers remain in the database, creating 2 sets of answers for SurveyID 5.

Any suggestions...if this is not too confusing?
Thanks!

View 1 Replies View Related

Cannot Add Or Delete Records

Dec 25, 2004

Hello all:

Form created based on a query. When i go to the form, the add new record and delete record buttons are disabled.

I have checked and re-checked the form, tables, queries and all seems well.

Does anyone know how I can fix this problem?

Many thanks,

Dion

View 2 Replies View Related

Delete Records Except First

Jun 1, 2014

possible to delete all records from one table except the first; Is that possible?

View 7 Replies View Related

Delete Records Problem

Jun 8, 2005

Good evening,

I am experiencing a problem with the delete buttons I have added into my forms. I have 3 different forms that operators use, I added a delete button using the wizard on each form to delete the data if the user makes a mistake. I have allowed deletes in the form properties. My problem is that the button only works on one of the forms. I have checked the code and it is the same on all 3 forms.

The record is not deleted, all that happens is that the vertical bar down the LHS of the form flashes black, and thats about it

Private Sub Command52_Click()
On Error GoTo Err_Command52_Click


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

Exit_Command52_Click:
Exit Sub

Err_Command52_Click:
MsgBox Err.Description
Resume Exit_Command52_Click

End Sub

Any thoughts?

The only difference is that one button is called Command52 and the other one is called Delete

Russ

View 4 Replies View Related

How To Delete Duplicate Records

Apr 30, 2007

Hello,

I have a table that has many duplicate records. I tried importing the table and setting the field to no duplicates but did not work. How can I delete duplicate records. The primary Id id fine I have another field that I can use. it is a BAC number that is repeated many times. Here is the table I need fixed.

Thanks

View 1 Replies View Related

Auto Delete Records?

Jul 29, 2005

I am creating a web database where users submit entries using an online form. When they submit the entry, I am saving the entry date and time in a column called Timestamp. What I need to figure out is if there is a way to create some sort of expiration date, based on the Timestamp, that will automatically delete a record after it is 7 days old. Is there a way to do this? Thanks so much for any help that you can give.

View 5 Replies View Related

Delete Multiple Records

May 9, 2007

how do i delete multiple records in a table, for example if i have a table that as serial_num 123 twice, how do i delete the two records, basically i don't want to delete one record, i want to delete the two records. Thanks.

View 5 Replies View Related

How To Delete Multiple Records

Aug 15, 2005

Hi,

I'm trying to delete say 4000 records, out of total 5000 records. I want to keep 1000 records based on the ID.

How can I write the SQL DELETE query, so that only 1000 records remain based on the query?

Thank you in advance for your great help.

regards,
Pranesh
Alberta, Canada

View 1 Replies View Related

Delete Records From A Table

Oct 26, 2005

Hi

I'm trying to deleterecords from one table. In the query there are 2 tables both joined. I get an error message come on saying

"Specify The Table Containing The Records you want to Delete"

Below is the query in SQL

DELETE tblStockRequired.StockCode, tblStockRequired.StockQTY, tblStockRequired.OrderNumber
FROM tblOrderCompleted INNER JOIN tblStockRequired ON (tblOrderCompleted.OrderNumber = tblStockRequired.OrderNumber) AND (tblOrderCompleted.StockCode = tblStockRequired.StockCode) AND (tblOrderCompleted.QTY = tblStockRequired.StockQTY);

I want ot delete all records from tblStockRequired which match up with tblOrderCompleted.

Thanks in Advanced

View 2 Replies View Related







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