Delete a record from a subform

J

joten

I have a form with a subform with a list of invoices in datashee
format. I'd like that clicking a button there is in the form eliminat
the record that is selected in the subform.

The code of the button is:
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

The problem is that the button works if I put it in the subform but no
in the form.

Thank you in advance
 
J

joten

Sorry, but following this subject I've just noted that I can delete
record but it is possible to edit it too. In order to avoid that I hav
modified the subform property 'allowedit' to false but then it is no
possible to delete records. How could I delete the records of th
subform without they can be edited?

Thank you in advance
 
V

Van T. Dinh

A Form (whether it is used as a normal Form or a Subform, i.e. SourceObject
of a Subform Control) has 2 distinct Properties: AllowEdits and
AllowDeletions. You should be able to set them (AllowEdits = False and
AllowDeletions = True) so that you can delete but not edit.

Even if you need the AllowEdits = True (which I doubt) to be able to delete,
you can code something like:

' Temporarily enable Edits if needed for deletions
Me!NameOfTheSubformControl.Form.AllowEdits = True
Me!NameOfTheSubformControl.SetFocus
' delete Record here ...
' Reset AllowEdits
Me!NameOfTheSubformControl.Form.AllowEdits = False

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

Top