How to delete a record

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm using Access 2003 and Windows XP. I would like to use an unbound main
form, with buttons, such as Add, Delete. The main form will have a datasheet
subform that is bound to a table.

I would like to code the delete button to delete the current record in the
subform. The user should be prompted if that want to delete the record(s).
Also, since the table is a parent of records in other tables, I would like to
inform the user if the record cannot be delete, since is it being referenced
by another table. I don't want to do a cascade delete.

Could someone help me with the coding to accomplish this task? Thanks.
 
Private Sub DeleteAccount_Click()
On Error GoTo Err_DeleteAccount_Click

Forms!company!Form_SubForm.SetFocus
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 12, , acMenuVer70

Exit_DeleteAccount_Click:
Exit Sub

Err_DeleteAccount_Click:
MsgBox Err.Description
Resume Exit_DeleteAccount_Click

End Sub
 
Joseph,

Thanks for your reply. I get no message when I try to delete a parent
record that has a child record. I also do not get any type of error message
from the On Error. To the user it may appear the delete has occurred, when
in fact it has not.

Regards,
Leif
 
Back
Top