putting delete command button in a form that has subform

mykil

My Life is Boring
Local time
Today, 08:54
Joined
Aug 16, 2011
Messages
117
Hi all!!! Does anybody knows what is the code for a delete command button in a form that has subform which are related to each other?


Thanks in advance!!!
 
The delete button can simply fire a Delete query. The trick though is identifying the records you wish to delete.
 
... how are your identifying the records you wish to delete?
 
I want the delete button delete the record in the main form which I selected as will as the data in the subform which is related to the main form's record... The form and subform are link together through a relationship...
 
If it's the current record then use the following in the criteria of your query;
Code:
[Forms]![YourMainFormName]![YourRecordID]
As a start create your query as a select query first, and ensure that it is selecting the record and sub-records that you wish, once you are happy with it's performance convert it to a delete query.

As part of the code you are using you will want to requery the form once the delete query has been run.
 
Where should I start? Could you give me the step by step direction John...:D
 
From the Code Module of a Form, invoke Access Help, and enter Relation Object. Now click on Relation Object (DAO), read the article as you scroll down until you see the "Cascading Deletes" link and follow it. It should give you help in how to set up so that when a Parent Record is deleted so are any Child Records.

Linq ;0)>
 
From the Code Module of a Form, invoke Access Help, and enter Relation Object. Now click on Relation Object (DAO), read the article as you scroll down until you see the "Cascading Deletes" link and follow it. It should give you help in how to set up so that when a Parent Record is deleted so are any Child Records.

I couldn't find the "Cascading Deletes" link...Is it a VBA code.. Do you have a sample Database which has a form with subform (Parent Record and Child Records)?
 
Thanks to both of you guys for helping.... I think I've got the answer.. I've just never notice the "Cascade Delete Related Records" when making a relationship between tables...:D
 

Users who are viewing this thread

Back
Top Bottom