By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,480 Members | 2,183 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,480 IT Pros & Developers. It's quick & easy.

Basic Record Manipulation

P: n/a
I've got two instances of one subform within my master form. I want
to programatically delete the current record of one of the subforms
when it is new and not editted or certain fields contain certain
values. This seems rather obvious but I'm new to Access 97.

Thanks.
Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
If the subform row is "new and not edited" then you are talking about the
new record row. You can remove it by setting the subform's AllowAdditions
property to No. However, if there are no records to display, the entire
detail section of the subform will go completely blank.

If you actually want to delete the current record in the subform, using code
in the main form's module, try something like this:

Dim frm As Form
Dim rs As DAO.Recordset

Set frm = Me.[NameOfYourSubformControlHere].Form
If frm.Dirty Then 'Undo any edits
frm.Undo
End If

If Not frm.NewRecord Then
Set rs = frm.RecordsetClone
rs.Bookmark = frm.Bookmark
rs.Delete
End If

Me.[NameOfYourOtherSubformHere].Requery

Set rs = Nothing
Set frm = Nothing

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Weaver" <we*****@verizon.net> wrote in message
news:66**************************@posting.google.c om...
I've got two instances of one subform within my master form. I want
to programatically delete the current record of one of the subforms
when it is new and not editted or certain fields contain certain
values. This seems rather obvious but I'm new to Access 97.

Thanks.

Nov 13 '05 #2

P: n/a
Thanks a lot, Allen. I don't think I would have ever figured this out.


"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message news:<41***********************@per-qv1-newsreader-01.iinet.net.au>...
If the subform row is "new and not edited" then you are talking about the
new record row. You can remove it by setting the subform's AllowAdditions
property to No. However, if there are no records to display, the entire
detail section of the subform will go completely blank.

If you actually want to delete the current record in the subform, using code
in the main form's module, try something like this:

Dim frm As Form
Dim rs As DAO.Recordset

Set frm = Me.[NameOfYourSubformControlHere].Form
If frm.Dirty Then 'Undo any edits
frm.Undo
End If

If Not frm.NewRecord Then
Set rs = frm.RecordsetClone
rs.Bookmark = frm.Bookmark
rs.Delete
End If

Me.[NameOfYourOtherSubformHere].Requery

Set rs = Nothing
Set frm = Nothing

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Weaver" <we*****@verizon.net> wrote in message
news:66**************************@posting.google.c om...
I've got two instances of one subform within my master form. I want
to programatically delete the current record of one of the subforms
when it is new and not editted or certain fields contain certain
values. This seems rather obvious but I'm new to Access 97.

Thanks.

Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.