currentrecord exiting a subform

G

Guest

Hello i have a form with a tab control that has a subform on its first page
On the main form there's a command button that call a routine in the module for the form underlaying the subform
This routine checks to see if the record currently showed on the subform should be manteined or deleted (it's already saved in the table because by clicking a command button outside the subform, the update event for the form underlying the subform has happened)
Thus I tried the me.recordset.delete because i suppouse that doing so I will affect the record that is currently showed in the subform which should be the current record (cycle property is settled to "current record")
But it seems it deletes the first record in the table and not the one showed. Why? It seems like if the counter reset exiting the subform or somewhat similar. Anyone who can give me suggestion on what happens exiting a subform
 
A

Allen Browne

To delete the current record in the subform from code in the main form's
module, use something like this:

With Me.[NameOfSubformControlHere].Form
If .Dirty Then
.Undo
End If
If Not .NewRecord Then
.RecordsetClone.Bookmark = .Bookmark
.RecordsetClone.Delete
End If
End With

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

rocco said:
Hello i have a form with a tab control that has a subform on its first page.
On the main form there's a command button that call a routine in the
module for the form underlaying the subform.
This routine checks to see if the record currently showed on the subform
should be manteined or deleted (it's already saved in the table because by
clicking a command button outside the subform, the update event for the form
underlying the subform has happened).
Thus I tried the me.recordset.delete because i suppouse that doing so I
will affect the record that is currently showed in the subform which should
be the current record (cycle property is settled to "current record").
But it seems it deletes the first record in the table and not the one
showed. Why? It seems like if the counter reset exiting the subform or
somewhat similar. Anyone who can give me suggestion on what happens exiting
a subform?
 

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