Two Delete Record Problems

  • Thread starter skyrise via AccessMonster.com
  • Start date
S

skyrise via AccessMonster.com

I have a database where I am trying to resolve two issues with deleting
records.

The first issue is that I can’t delete a row in the subforms. The shortcut
menu does not enable the “cut†option. Selecting/Highlighting the row and
pressing Delete on the keyboard doesn’t work. I have to go to the table for
the subform in order to delete the row. I don’t remember experienced this
problem before, and don’t know the cause or how to change it.

The second solution I am seeking is to be able to use the Delete Record
button to delete the main form record and the matching subform records that
have the same record ID number (up to 15 subforms with multiple rows). The
wizard-generated button builds a macro that deletes the main form record but
not the subform records. I’m trying to find programming code that might
delete everything at one time.

Thanks for any help that you can provide.
 
J

Jeanette Cunningham

Hi skyrise,
It's a fact that with some queries, you can't delete from the query.
If your form has such a query as its record source, then you won't be able
to delete from the subform using the delete button.

To delete a main form and matching subform records, you will probably find
that the child records need to be deleted before the parent records.

In code you can use-->

Private Sub DeleteBtn_Click()
Dim strSQL As String

strSQL = "MyQueryForChildRecords"
CurrentDb.Execute strSQL, dbFailOnError

strSQL = "MyQueryForParentRecords"
CurrentDb.Execute strSQL, dbFailOnError

End Sub

MyQueryFor ... can be a saved query or it can be the sql of a query pasted
into the code.



Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 

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

Top