Delete Current Record In Subform

  • Thread starter Thread starter Maria
  • Start date Start date
M

Maria

Is there another way to delete the current record in a subform from the main
form, another subform or a sub-subform other than setting focus on a field
in the subform and using run command acCmdDelete Record?

Thanks!

Maria
 
You can use the Execute Method to run a Delete Query in code.

However, if the Subform (which shows the deleted Record) is visible, you
will need to re-query the Subform to remove the deleted "row" from the
RecordSource. Otherwise, you Subform will show a row of "#Deleted" entries.

The acCmdDeleteRecord looks after the Requery for you.
 
Van,

A Delete Query works off a table so somehow you have to identify the primary
key value of the record you want to delete. acCmdDeleteRecord works off the
form and automatically knows which record to delete - the current record.
I'm looking for another method that works off the form and knows to delete
the current record. I have a subform several layers deep where I want to
delete the current record. It takes a lot of lines of code to set focus on
the record. I'm looking for a simpler way to delete the record.

Maria
 
Not AFAIK beside setting Focus on the SubForm then SubSubForm then
SubSubSubform ...

OTOH, I limit my user interface to ONE level of Subforms. In my experience,
users get very confused with nested Subforms. Afterall, the users don't
know and don't need to know the relationships between Tables like developers
are supposed to know.
 
Back
Top