deleting a record in a subform from VBA code in the main form

  • Thread starter Thread starter Paul James
  • Start date Start date
P

Paul James

I would like to have a line of VBA code in a procedure based on an event in
a main form that deletes the current record in a subform. My objects are
named as follows:

Main form: frmReceipt
Subform control name: ctl_ReceiptSub
Subform name: frmReceiptSub

Thanks in advance,

Paul
 
Add a MsgBox() if you want a warning:

Dim frm As Form
Set frm = Me.ctl_ReceiptSub.Form
If frm.NewRecord Then
Beep
Else
With frm.RecordsetClone
.Bookmark = frm.Bookmark
.Delete
End With
End If
Set frm = Nothing
 
Thanks for the code, Allen.

Sorry for the delay in responding. I didn't install it until now, and I
wanted to try it out first in case I had any comments.

It works great.

Paul
 
Back
Top