Hi everybody,
I have a button on the main form to delete records on a subform. I use this code:
Private Sub BtnDeleteContact_Click()
Dim Respons As String
Dim Msg, Style, Title, Response As String
Msg = "You are about to delete this contact."
Style = vbOKCancel + vbQuestion + vbDefaultButton2
Title = "Continue?"
Response = MsgBox(Msg, Style, Title)
If Response = vbOK Then
Me!subfrmCustomerContacts.Form.AllowDeletions = True
Me.subfrmCustomerContacts.SetFocus
Me.subfrmCustomerContacts.Form.Recordset.Delete
Me.subfrmCustomerContacts.Form.Recordset.MoveNext
Else
MsgBox "No record deleted", vbOKOnly, "No changes made"
End If
Me!subfrmCustomerContacts.Form.AllowDeletions = False
End Sub
Now this works fine for all records EXCEPT the last one on the subform. Can somebody explain to me why and if it is possible to also delete the last record.
Appreciate your replies.
Cheers.
I have a button on the main form to delete records on a subform. I use this code:
Private Sub BtnDeleteContact_Click()
Dim Respons As String
Dim Msg, Style, Title, Response As String
Msg = "You are about to delete this contact."
Style = vbOKCancel + vbQuestion + vbDefaultButton2
Title = "Continue?"
Response = MsgBox(Msg, Style, Title)
If Response = vbOK Then
Me!subfrmCustomerContacts.Form.AllowDeletions = True
Me.subfrmCustomerContacts.SetFocus
Me.subfrmCustomerContacts.Form.Recordset.Delete
Me.subfrmCustomerContacts.Form.Recordset.MoveNext
Else
MsgBox "No record deleted", vbOKOnly, "No changes made"
End If
Me!subfrmCustomerContacts.Form.AllowDeletions = False
End Sub
Now this works fine for all records EXCEPT the last one on the subform. Can somebody explain to me why and if it is possible to also delete the last record.

Appreciate your replies.

Cheers.