Delete current record in a subform

  • Thread starter Thread starter Dou
  • Start date Start date
D

Dou

How to Delete current record in a subform using a command button? But it
still show other records.

Thanks
 
With Me.[NameOfYourSubformControlHere].Form
If .NewRecord Then
Beep
Else
.RecordsetClone.Bookmark = .Bookmark
.RecordsetClone.Delete
End If
End With
 
Thanks, I use your code, it can delete the selected record,
but after Requery subform, other record cann'r be shown, like this:

With Me![OrderAddSubform].Form
If .NewRecord Then
Beep
Else
.RecordsetClone.Bookmark = .Bookmark
.RecordsetClone.Delete
Me![OrderAddSubform].Requery
End If
End With


Allen Browne said:
With Me.[NameOfYourSubformControlHere].Form
If .NewRecord Then
Beep
Else
.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.

Dou said:
How to Delete current record in a subform using a command button? But it
still show other records.

Thanks
 
Not sure why the Requery is needed, but try:
.Requery

I would expect the focus to move to the first record in the subform after
the requery.

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

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

Dou said:
Thanks, I use your code, it can delete the selected record,
but after Requery subform, other record cann'r be shown, like this:

With Me![OrderAddSubform].Form
If .NewRecord Then
Beep
Else
.RecordsetClone.Bookmark = .Bookmark
.RecordsetClone.Delete
Me![OrderAddSubform].Requery
End If
End With


Allen Browne said:
With Me.[NameOfYourSubformControlHere].Form
If .NewRecord Then
Beep
Else
.RecordsetClone.Bookmark = .Bookmark
.RecordsetClone.Delete
End If
End With


Dou said:
How to Delete current record in a subform using a command button? But
it
still show other records.

Thanks
 
This subform's Recordsource is a table, After deleted a record and use
..Requery,
other records still cann't be shown. I want to show these records.
Thanks
 
When you delete one record, the others are disappearing as well?

I don't understand that. Are they still in the related table?
Or have they been deleted from your table as well?
 
When I delete one record, the others still in the related table.
I hope that others still can be shown and can add a new record after deleted
a record in this subform. Now I can add new record ,but cann't show others
record in the table.

Thanks
 
So the other records were showing in the subform before the delete. After
the delete they are still in the table, and they are still there in the
subform unless you requery. But after you requery the subform, they
disappear???

I don't understand why that would be so. They should still be there.
 
I have solved this problem. thanks.

Allen Browne said:
So the other records were showing in the subform before the delete. After
the delete they are still in the table, and they are still there in the
subform unless you requery. But after you requery the subform, they
disappear???

I don't understand why that would be so. They should still be there.
 
Back
Top