Delete Record in Sub Form

  • Thread starter Thread starter XMan
  • Start date Start date
X

XMan

How can I delete a record in sub-form? I'm looking to have a Delete button
in the sub-form and delete that record only. TIA.
 
How about about the sub form is continuous and I need one Delete button.
Only delete the record where cursor is at. TIA.
 
Since the code is running in the context of the SubForm, you can simply use:

DoCmd.RunCommand acCmdDeleteRecord

in the Click Event Procedure of the Delete CommandButton.
 
The code I post only delete a "block" of Records if there
is a selected "block". If there is no "block", the Command
will delete the CurrentRecord.

To ensure that the user deletes the right Record, I
normally use the Form in CtsFormView and put the Delete
button in the Detail section. This way, the user see
instances of the Delete button and whichever instance
he/she clicks, the associated Record becomes the
CurrentRecord which will be deleted then.

It goes without saying that you should ask the user to
confirm before deletion.

HTH
Van T. Dinh
MVP (Access)
 
Van, Thanks for your great help.


Van T. Dinh said:
The code I post only delete a "block" of Records if there
is a selected "block". If there is no "block", the Command
will delete the CurrentRecord.

To ensure that the user deletes the right Record, I
normally use the Form in CtsFormView and put the Delete
button in the Detail section. This way, the user see
instances of the Delete button and whichever instance
he/she clicks, the associated Record becomes the
CurrentRecord which will be deleted then.

It goes without saying that you should ask the user to
confirm before deletion.

HTH
Van T. Dinh
MVP (Access)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top