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

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
 
A

Allen Browne

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
 
P

Paul James

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
 

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